Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 3.1k
Description
Feature Request
An option to recursively type-check all.py files under a given directory when using namespace_packages (without __init__.py).
Use Case
Given the following directory structure:
my-py3-repo/ ├── hello/ │ ├── services/ │ │ └── hello_service.py │ └── hello.py ├── scripts/ │ ├── db/ │ │ └── migrate.py │ └── manage.py └── tests/ └── hello/ ├── services/ │ └── hello_service_test.py └── hello_test.py Assuming that hello.py imports hello_service.py, everything under the hello namespace will be type checked as expected with mypy ./hello.
However test discovery with pytest, nose, django et al works differently and hello_test.py would not usually import hello_service_test.py. There is currently no way for Mypy to discover hello_service_test.py with mypy ./tests (if not using __init__.py).
Similarly, everything under the scripts directory would suffer the same problem.
If Mypy supported a --recursive -r option (or similar) that would cause it to automatically recurse into subdirectories, this would solve these common use cases.
Why not just use __init__.py?
To quote iScrE4m's comment from #1645 (comment)_,
In future, there will be python programmers who never heard of pre PEP420 era of
__init__.pyand that's good. What's not good is mypy forcing them to create dummy files.
Configuration
# Pipfile [dev-packages] mypy = "==0.670" [requires] python_version = "3.7"# setup.cfg [mypy] python_version = 3.7 ignore_missing_imports = True namespace_packages = True