Title: [Feature Request] Option to Recurse into All Subdirectories with Namespace Packages · Issue #6385 · python/mypy · GitHub
Open Graph Title: [Feature Request] Option to Recurse into All Subdirectories with Namespace Packages · Issue #6385 · python/mypy
X Title: [Feature Request] Option to Recurse into All Subdirectories with Namespace Packages · Issue #6385 · python/mypy
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/ │ │ ...
Open Graph 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-p...
X 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-p...
Opengraph URL: https://github.com/python/mypy/issues/6385
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Feature Request] Option to Recurse into All Subdirectories with Namespace Packages","articleBody":"**Feature Request**\r\nAn option to recursively type-check _all_ `.py` files under a given directory when using `namespace_packages` (without `__init__.py`).\r\n\r\n**Use Case**\r\nGiven the following directory structure:\r\n```\r\nmy-py3-repo/\r\n├── hello/\r\n│ ├── services/\r\n│ │ └── hello_service.py\r\n│ └── hello.py\r\n├── scripts/\r\n│ ├── db/\r\n│ │ └── migrate.py\r\n│ └── manage.py\r\n└── tests/\r\n └── hello/\r\n ├── services/\r\n │ └── hello_service_test.py\r\n └── hello_test.py\r\n```\r\nAssuming that `hello.py` imports `hello_service.py`, everything under the `hello` namespace will be type checked as expected with `mypy ./hello`.\r\n\r\nHowever 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`).\r\n\r\nSimilarly, everything under the `scripts` directory would suffer the same problem.\r\n\r\nIf Mypy supported a `--recursive -r` option (or similar) that would cause it to automatically recurse into subdirectories, this would solve these common use cases.\r\n\r\n**Why not just use `__init__.py`?**\r\nTo quote `iScrE4m`'s comment from https://github.com/python/mypy/issues/1645#issuecomment-302948133_,\r\n> 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.\r\n\r\n**Configuration**\r\n```bash\r\n# Pipfile\r\n[dev-packages]\r\nmypy = \"==0.670\"\r\n[requires]\r\npython_version = \"3.7\"\r\n```\r\n```bash\r\n# setup.cfg\r\n[mypy]\r\npython_version = 3.7\r\nignore_missing_imports = True\r\nnamespace_packages = True\r\n```\r\n","author":{"url":"https://github.com/jtschoonhoven","@type":"Person","name":"jtschoonhoven"},"datePublished":"2019-02-13T18:43:05Z","url":"https://github.com/python/mypy/issues/6385"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:fa402ab2-9640-ae56-393f-e37eb6e44f04 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9AB8:30501:271C92:354BD2:6B0024EB |
| html-safe-nonce | c97f4cf0be909d8c63050931f413a7c412ed3944fdfb47368bfd61c814ece9a1 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QUI4OjMwNTAxOjI3MUM5MjozNTRCRDI6NkIwMDI0RUIiLCJ2aXNpdG9yX2lkIjoiODA2NjI2OTQzMzg5NjcyNjgzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 83775cc874baab68951812c631b59a18ef1c0b61248b16fd6c27c0ef6952e3a7 |
| hovercard-subject-tag | issue:409946546 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/mypy/6385/issue_layout |
| twitter:image | https://opengraph.githubassets.com/910b2ff139f9c08d4bd8494cb4b6df3833e5b41cac345f9efc33f29c880ac2ef/python/mypy/issues/6385 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/910b2ff139f9c08d4bd8494cb4b6df3833e5b41cac345f9efc33f29c880ac2ef/python/mypy/issues/6385 |
| og:image:alt | 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-p... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jtschoonhoven |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4eb4cba0d69f045374ac15de9666d22b0961e1d555cc3824f36b7734c00c78e0 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/mypy git https://github.com/python/mypy.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 7053637 |
| octolytics-dimension-repository_nwo | python/mypy |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 7053637 |
| octolytics-dimension-repository_network_root_nwo | python/mypy |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 44c658b24abf00491fb7ae5f56d42c9f38cbeab2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width