♻️ refactor: group private modules under public packages#613
Merged
gaborbernat merged 3 commits intoJul 8, 2026
Conversation
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.
Merging this PR will not alter performance
Comparing Footnotes
|
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.
7299e81 to
512a26e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The C tree groups by intent (
parse,dom,query,css,js,clean,extract,serialize,core), but the Python side stayed flat: sixteen private_*.pyhelpers sat in one directory beside the public modules, so finding the code behindextractorcleanmeant 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,queryandcleanmodules become packages whose__init__.pycarries 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_internalpackage (_render,_minify,_jsminify,_cssmin,_selectors,_locations). Every in-repo import, themeson.buildinstall lists, and the.pyistubs follow the moves.Public import paths do not change:
turbohtml.extract,turbohtml.queryandturbohtml.cleanstay importable through their package__init__, and every name in each module's__all__and inturbohtml.__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 the1.0.0tag to confirm no public removal, rename, or signature change. ✅The test tree mirrors the same grouping: the URL primitive tests move to
tests/extract/urlnext to where_urlsnow lives, and every test that reached for a moved private module points at its new path.