Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for
.pyi
type stubs (including for first-party) (#10759)
There are two use cases for writing `.pyi` type stubs: 1) Writing bindings for third party libraries. 2) Writing stubs for your own code because you prefer it over using type hints/comments. This PR adds support for both use cases. We allow Python targets to now include `.pyi` files, and update the default globs for `python_library` and `python_tests` to include them. We also teach dependency inference about `.pyi` files. For third party reqs, we infer a dep on both the req and the `.pyi` file. For first party stubs, we infer a dep on both the `.py` and `.pyi` files. Most of our Python functionality works correctly without changes for `.pyi` files, but we have to teach Pytest to not try running over `.pyi` files if they show up in `python_tests` targets, just like we special case `conftest.py`. We also update how we call MyPy; if there is a `.pyi` file and `.py` file, the `.pyi` file takes precedence; otherwise, MyPy would error. [ci skip-rust] [ci skip-build-wheels]
- Loading branch information
1 parent
5f46286
commit f90b982
Showing
18 changed files
with
483 additions
and
184 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Oops, something went wrong.