Skip to content

♻️ refactor: group private modules under public packages#613

Merged
gaborbernat merged 3 commits into
tox-dev:mainfrom
gaborbernat:refactor/py-package-grouping
Jul 8, 2026
Merged

♻️ refactor: group private modules under public packages#613
gaborbernat merged 3 commits into
tox-dev:mainfrom
gaborbernat:refactor/py-package-grouping

Conversation

@gaborbernat

Copy link
Copy Markdown
Member

The C tree groups by intent (parse, dom, query, css, js, clean, extract, serialize, core), but the Python side stayed flat: sixteen private _*.py helpers sat in one directory beside the public modules, so finding the code behind extract or clean meant scanning the whole package. This regroups each private helper under the public module that owns it, so the layout reads the same way on both sides of the extension boundary. 🧭

The public extract, query and clean modules become packages whose __init__.py carries the same code and re-exports the same names, with their private helpers moved alongside (extract/_urls.py, query/_match.py, clean/_sanitizer.py, and so on). The six helpers pulled in by more than one subsystem or by the package root move to a new _internal package (_render, _minify, _jsminify, _cssmin, _selectors, _locations). Every in-repo import, the meson.build install lists, and the .pyi stubs follow the moves.

Public import paths do not change: turbohtml.extract, turbohtml.query and turbohtml.clean stay importable through their package __init__, and every name in each module's __all__ and in turbohtml.__all__ is byte-identical to before. Only underscore-private module paths moved, and those are not part of the public API. The surface was diffed against the 1.0.0 tag to confirm no public removal, rename, or signature change. ✅

The test tree mirrors the same grouping: the URL primitive tests move to tests/extract/url next to where _urls now lives, and every test that reached for a moved private module points at its new path.

Mirror the intent grouping of the C tree on the Python side. The public
extract, query and clean modules become packages that own their private
helpers, and the cross-cutting helpers move to a new _internal package.

Public import paths are unchanged: turbohtml.extract et al. stay
importable via each package __init__, and every name re-exported from
turbohtml stays put. Only underscore-private module paths move, with
every in-repo reference updated.
@gaborbernat gaborbernat added the enhancement New feature or request label Jul 8, 2026
@codspeed-hq

codspeed-hq Bot commented Jul 8, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 91 untouched benchmarks
⏩ 18 skipped benchmarks1


Comparing gaborbernat:refactor/py-package-grouping (6b4fb92) with main (9cc182c)

Open in CodSpeed

Footnotes

  1. 18 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

Move the URL primitive tests under tests/extract/url to match where the
_urls helper now lives, and point every test that imports a moved
private module at its new path.
@gaborbernat gaborbernat force-pushed the refactor/py-package-grouping branch from 7299e81 to 512a26e Compare July 8, 2026 14:45
@gaborbernat gaborbernat merged commit 6496744 into tox-dev:main Jul 8, 2026
50 checks passed
@gaborbernat gaborbernat deleted the refactor/py-package-grouping branch July 8, 2026 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant