You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allow listing modules/packages to check, within the MyPy config files.
Pitch
Today, it is possible to use the files config item (in mypy.ini, pyproject.toml, etc.) to tell MyPy what files to check. You can also do this on the command-line, by simply listing the files.
If you want MyPy to check an entire module or package, you can do so on the command line (with -m or -p), but there is no way to do this in a config file. Since it is possible to set files in config files, I think it should also be possible to set module and package. (I am suggesting not-plural names "module" and "package" to match the command-line arguments).
One question you might ask is "Why don't you just list the directory containing your modules/packages?" In my case, doing so gives me an error like this:
src/namespace1/namespace2/package1/file.py: error: Source file found twice under different module names: `package2` and `namespace1.namespace2.package2`
… or an error like this:
src/namespace1/namespace2/package1/__init.py__:NN: error: Skipping analyzing "namespace1": found module but no type hints of library stubs
All of my code is in the src directory. In my pyproject.toml, I have namespace_packages = true and mypy_path = ["src"]. The above error only happens if I try to specify a file or directory to check. If instead I use -p namespace1 (or -p namespace1.namespace2), everything is located, loaded, and typechecked successfully.
Activity
hauntsaninja commentedon Jun 28, 2021
Reasonable feature request.
(Note for namespace package file listing, I think using
--explicit-package-basescan solve that issue, see https://mypy.readthedocs.io/en/latest/running_mypy.html#mapping-file-paths-to-modules)MyPy: Switch to package-discovery, instead of file-discovery
Support package and module in config file (#13404)