Skip to content

Prepare for adding a py.typed file by moving pytest.py to a package#6302

Closed
bluetech wants to merge 1 commit intopytest-dev:featuresfrom
bluetech:pytest-pkg-dir
Closed

Prepare for adding a py.typed file by moving pytest.py to a package#6302
bluetech wants to merge 1 commit intopytest-dev:featuresfrom
bluetech:pytest-pkg-dir

Conversation

@bluetech
Copy link
Member

@bluetech bluetech commented Dec 1, 2019

While this commit does not do it yet, we want to eventually publish
pytest's type annotations. According to PEP561, this is done by adding a
py.typed file to each top-level package, pytest and _pytest in
pytest's case. However, the pytest package is currently just a single
module/file, so it's not possible to added to file to it.

Change pytest to a package (i.e. a directory with __init__.py), then
adding a py.typed file to it is possible.

The reason for doing it already is that it makes it easy to ask people
to test the types just by touching a couple of files.

@bluetech
Copy link
Member Author

bluetech commented Dec 1, 2019

I hope I made this maneuver successfully - I am not an expert in packaging.

References this comment: #3342 (comment)

Also, looking into _setup_collect_fakemodule(), it looks like a backward compat thing which sets up a pytest.collect module dynamically. I wonder if it is still necessary in pytest 5? pytest's own code only uses it in an orphan doc example, doc/en/example/py2py3/. I tried searching in GitHub code search for pytest.collect but it's hard to narrow down.

@RonnyPfannschmidt
Copy link
Member

we should turn it into a deprecated feature so we can remove it later, it might still be used in legacy/private code bases

While this commit does not do it yet, we want to eventually publish
pytest's type annotations. According to PEP561, this is done by adding a
`py.typed` file to each top-level package, `pytest` and `_pytest` in
pytest's case. However, the `pytest` package is currently just a single
module/file, so it's not possible to added to file to it.

Change `pytest` to a package (i.e. a directory with `__init__.py`), then
adding a `py.typed` file to it is possible.

The reason for doing it already is that it makes it easy to ask people
to test the types just by touching a couple of files.
@bluetech
Copy link
Member Author

bluetech commented Dec 2, 2019

Closing in favor of #6304.

@bluetech bluetech closed this Dec 2, 2019
@bluetech bluetech deleted the pytest-pkg-dir branch February 28, 2020 12:08
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.

2 participants