-
-
Notifications
You must be signed in to change notification settings - Fork 645
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Type stubs should be registered as normal requirements, not in `[mypy…
…].extra_requirements` (#12597) ### Background Before Pants 2.6, using third-party type stubs was awkward because [we did not yet have dependency inference](https://blog.pantsbuild.org/introducing-pants-2-6/). Instead, you either had to explicitly add the dependency or hijack `[mypy].extra_requirements`. The latter would mean installing the dep more times than it's actually needed. To allow putting type stubs in `[mypy].extra_requirements`, we had to install those deps _both_ in the `mypy.pex` tool PEX, and in the `typechecked_venv.pex`, which is a `VenvPex` where we grab the Python interpreter to point MyPy's `--python-executable` at. This meant installing `[mypy].extra_requirements` twice. ### Solution Instead, `[mypy].extra_requirements` should only be used for what is needed to run MyPy itself, such as MyPy plugins. It should not include type stubs, which should be installed via normal dependencies like in `requirements.txt`. Clearing this up has the benefits of: - bringing conceptual clarity - not installing `[mypy].extra_requirements` twice - facilitating adding a tool lockfile for MyPy ### Awkward bit: MyPy plugins w/ type stubs embedded Some requirements like `django-stubs` both act as a MyPy plugin and include type stubs. In fact, `django-stubs` was the motivating case for the original implementation. Now, you will need to install `django-stubs` and its kin in both `[mypy].extra_requirements` (for the plugin part) and as a normal dependency (for the type stubs). (The duplication of requirement strings could be solved by #12449). This is awkward, but conceptually sound. [ci skip-rust] [ci skip-build-wheels]
- Loading branch information
1 parent
7d9d405
commit fe9a2e2
Showing
2 changed files
with
29 additions
and
32 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