Repository navigation
Replace py.path.local usage with pathlib in PEP 517 tests - #10770
Open
watany-dev wants to merge 1 commit into
Open
watany-dev wants to merge 1 commit into
watany-dev wants to merge 1 commit into
Conversation
The test module imported the legacy 'py' package solely to call py.path.local(...).join(...).check() for one assertion. The 'py' package is not declared in any of the project requirements, so the import only resolves accidentally (via pytest's internal compat shim). Use pathlib.Path instead, which is already imported in this module.
Author
|
For context, I came across this minor issue while testing chokkin, a dead-code detection tool I’m developing. |
This branch has not been deployed
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.
Summary
tests/backends/test_pep517.pyimported the legacypypackage solely for one assertion usingpy.path.local(...).join(...).check()pyis not declared in any of the project's requirement files (it only resolves accidentally via pytest's internal compat shim,_pytest._py), so the import is fragileChanges
import pypy.path.local(...).join(...).check()assertion with the equivalentpathlib.Path(...).joinpath(...).exists()(pathlibwas already imported in this module)Testing
pytest tests/backends/test_pep517.py— 8 passed, exercising bothtest_build_sdistandtest_build_wheelend-to-end builds.uvx chokkin --strict) no longer reports the unresolvedpyimport (CHK010).Related
chokkindead-code/undeclared-import analysis (CHK010, confidence: likely).