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__.py and 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
Feature Request
An option to recursively type-check all
.pyfiles under a given directory when usingnamespace_packages(without__init__.py).Use Case
Given the following directory structure:
Assuming that
hello.pyimportshello_service.py, everything under thehellonamespace will be type checked as expected withmypy ./hello.However test discovery with
pytest,nose,djangoet al works differently andhello_test.pywould not usually importhello_service_test.py. There is currently no way for Mypy to discoverhello_service_test.pywithmypy ./tests(if not using__init__.py).Similarly, everything under the
scriptsdirectory would suffer the same problem.If Mypy supported a
--recursive -roption (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)_,Configuration
# setup.cfg [mypy] python_version = 3.7 ignore_missing_imports = True namespace_packages = True