Skip to content

Replace py.path.local usage with pathlib in PEP 517 tests - #10770

Open
watany-dev wants to merge 1 commit into
aws:v2from
watany-dev:fix/replace-py-pathlocal-with-pathlib
Open

watany-dev wants to merge 1 commit into
aws:v2from
watany-dev:fix/replace-py-pathlocal-with-pathlib

Conversation

@watany-dev

Copy link
Copy Markdown

Summary

  • tests/backends/test_pep517.py imported the legacy py package solely for one assertion using py.path.local(...).join(...).check()
  • py is 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 fragile

Changes

  • Drop the top-level import py
  • Replace the py.path.local(...).join(...).check() assertion with the equivalent pathlib.Path(...).joinpath(...).exists() (pathlib was already imported in this module)

Testing

  • Ran pytest tests/backends/test_pep517.py — 8 passed, exercising both test_build_sdist and test_build_wheel end-to-end builds.
  • Dead-code analysis (uvx chokkin --strict) no longer reports the unresolved py import (CHK010).

Related

  • Flagged by chokkin dead-code/undeclared-import analysis (CHK010, confidence: likely).

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.
@watany-dev
watany-dev requested a review from a team as a code owner October 17, 2026 04:55
@watany-dev

Copy link
Copy Markdown
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

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant