pytest-dev / pytest-dev/pytest
Missing type exports for vendored `py`
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 14.5k
- Forks
- 3.4k
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 35
Description
I want to report a side effect of this change when using mypy. py used to be typed, while apparently the vendored library is not. Downstream developers that define pytest hooks may now see mypy errors like:
nbvalx/pytest_hooks_notebooks.py:32: error: Skipping analyzing "py": module is
installed, but missing library stubs or py.typed marker [import]
import py
^
nbvalx/pytest_hooks_notebooks.py:32: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
nbvalx/pytest_hooks_notebooks.py:412: error: Argument 2 to "collect_file"
becomes "Any" due to an unfollowed import [no-any-unimported]
def collect_file(file_path: pathlib.Path, path: py.path.local, parent:...
^
I'll leave it to you to decide if it is worth it to add back that support (downstream developers can easily add a couple of ignores, especially knowing that py.path is being deprecated anyway), but I want to report this here for future reference because at the beginning I couldn't wrap my head around what had happened (latest py release was one year ago, and surely I had ran my CI last week without errors) and it took me a while to figure out what was going on.
Cheers,
Francesco
Originally posted by @francesco-ballarin in https://github.com/pytest-dev/pytest/issues/10396#issuecomment-1291525602
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the mypy run against nbvalx/pytest_hooks_notebooks.py, especially lines 32 and 412, and inspect the change that replaced the typed py dependency with the vendored library. Done means the supported approach for pytest hook users is established and the reported missing-stub and Any errors are resolved or explicitly documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100