Repository navigation
👷 ci: enforce lazy imports with flake8-lazy - #1088
Merged
Merged
Conversation
The codebase declares deferred imports in __lazy_modules__ to keep CLI startup fast, but nothing checked the lists stayed in sync, so they had drifted. Add henryiii's flake8-lazy pre-commit hook to catch missing or stale declarations going forward. Scope it to src/ since deferred imports only matter for the shipped package, not the test suite. Fixing the existing drift means declaring the parent packages flake8-lazy now requires (packaging, build._compat) in __main__ and adding pathlib to the tarfile compat shim.
gaborbernat
enabled auto-merge (squash)
June 4, 2026 14:21
layday
approved these changes
Jun 4, 2026
gaborbernat
pushed a commit
to gaborbernat/build
that referenced
this pull request
Jun 4, 2026
Satisfy the flake8-lazy check (merged in pypa#1088) for the imports this branch adds to __main__ and _util.
gaborbernat
pushed a commit
to gaborbernat/build
that referenced
this pull request
Jun 4, 2026
Satisfy the flake8-lazy check (merged in pypa#1088) for the imports this branch adds across __main__, _exceptions, _util and util.
Contributor
would make it autocorrect. |
Contributor
Author
|
Not possible today, unfortunately. Filed henryiii/flake8-lazy#75 to have |
gaborbernat
added a commit
that referenced
this pull request
Jun 6, 2026
* ✨ feat(deps): show wanted vs found in missing-deps error A --no-isolation build that hit an unmet requirement printed a flat list that could not distinguish an absent package from one installed at the wrong version, and never named the interpreter it inspected. Diagnosing issue #504 required stepping through the code with pdb to learn that a package the user had installed was simply invisible to the Python running build. The error now reports, per requirement, the version specifier wanted against the version found (or that the package is not installed), and names the interpreter checked. The public check_dependency and check_dependencies contracts are unchanged; only the rendering of their result is new, in build._util.format_unmet_dependencies. * 🔧 chore: declare new imports as lazy Satisfy the flake8-lazy check (merged in #1088) for the imports this branch adds to __main__ and _util. * 🔧 chore: call it 'Unmet dependencies' Address review: rename the error header from 'Missing dependencies' to 'Unmet dependencies', a better qualifier for a present-but-wrong-version case. Updated message, docs and tests. --------- Co-authored-by: Test <test@test.com>
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.
build keeps its command-line startup fast by deferring heavy imports, and each module records which ones in a
__lazy_modules__list. Nothing has been checking those lists, so they drifted out of sync with the actual imports. 🐌This adds
flake8-lazyas a pre-commit hook so the lists are verified on every change. It runs only againstsrc/, since deferred imports matter for the shipped package rather than the test suite. Bringing the current code back into compliance meant declaring the parent packages the hook now expects (packaging,build._compat) in__main__and giving thetarfilecompat shim a__lazy_modules__entry forpathlib.The lists are declarative, so there is no runtime behavior change; the value is catching a missing or stale declaration before it ships.