Title: Add support for pkgutil-style namespace packages · Issue #9393 · python/mypy · GitHub
Open Graph Title: Add support for pkgutil-style namespace packages · Issue #9393 · python/mypy
X Title: Add support for pkgutil-style namespace packages · Issue #9393 · python/mypy
Description: 🚀 Feature Add support for pkgutil-style namespace packages. Pitch In october 2018, PR #5691 brought support for PEP420 namespace packages (i.e. native namespace packages), which closed issue #1645. However, the native PEP420 method only ...
Open Graph Description: 🚀 Feature Add support for pkgutil-style namespace packages. Pitch In october 2018, PR #5691 brought support for PEP420 namespace packages (i.e. native namespace packages), which closed issue #1645....
X Description: 🚀 Feature Add support for pkgutil-style namespace packages. Pitch In october 2018, PR #5691 brought support for PEP420 namespace packages (i.e. native namespace packages), which closed issue #1645....
Opengraph URL: https://github.com/python/mypy/issues/9393
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Add support for pkgutil-style namespace packages","articleBody":"## 🚀 Feature\r\n\r\nAdd support for [pkgutil-style namespace packages](https://packaging.python.org/guides/packaging-namespace-packages/#pkgutil-style-namespace-packages).\r\n\r\n## Pitch\r\n\r\nIn october 2018, PR #5691 brought support for PEP420 namespace packages (i.e. [native namespace packages](https://packaging.python.org/guides/packaging-namespace-packages/#native-namespace-packages)), which closed issue #1645.\r\n\r\nHowever, the native PEP420 method only works for Python 3.\r\n> This type of namespace package is defined in PEP 420 and is available in Python 3.3 and later. This is recommended if packages in your namespace only ever need to support Python 3 and installation via pip.\r\n\r\nAccording to Python documentation, for Python 2/3 compatible code, the [pkgutil-style](https://packaging.python.org/guides/packaging-namespace-packages/#pkgutil-style-namespace-packages) remains the recommended way.\r\n> This is recommended for new packages that need to support Python 2 and 3 and installation via both pip and python setup.py install.\r\n\r\nLet the following project structure, with PYTHONPATH and MYPYPATH pointing to the `src/` and 'tests/src/' directories:\r\n```\r\nmy-project\r\n+-- src/\r\n| +-- mynamespace/\r\n| +-- __init__.py\r\n+-- tests/\r\n +-- data/\r\n +-- src/\r\n +-- mynamespace/\r\n +-- test/\r\n | +-- __init__.py\r\n +-- __init__.py\r\n```\r\nThe `mynamespace` namespace is splitted in two directories, in order not to mix up the test code with the deliverable code in this project.\r\nWithin both `src/mynamespace/__init__.py` and `tests/src/mynamespace/__init__.py`, the following code implements the pkgutil-style namespace package:\r\n```python\r\nfrom pkgutil import extend_path\r\n__path__ = extend_path(__path__, __name__)\r\n```\r\n\r\nPython 2 and Python 3 execute this code correctly.\r\n\r\nBut, unfortunately, mypy (as of 0.770) generates a false 'Duplicate module named 'mynamespace'' error (same error as the former #1645 issue).","author":{"url":"https://github.com/alxroyer","@type":"Person","name":"alxroyer"},"datePublished":"2020-09-01T23:52:35Z","url":"https://github.com/python/mypy/issues/9393"}
| 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:aa662d3a-bae5-34ae-8b84-033c936727d9 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E7C2:1756E4:1930003:213AE71:6B002C81 |
| html-safe-nonce | 8c9efb4d6288e3a19e6455f423bdbe790e73c65631213b95f86e846ef609d7a9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFN0MyOjE3NTZFNDoxOTMwMDAzOjIxM0FFNzE6NkIwMDJDODEiLCJ2aXNpdG9yX2lkIjoiNDE5NTEzODMxMjA3NzMyMzM5MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | fa127a7b9eb84363d502ef3d3a3a149c36d9717c23ad6f68e9e564d87da690b9 |
| hovercard-subject-tag | issue:690522315 |
| 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/9393/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c61ae09299c4744e454f553589d7c946cb42232eb5156679c36bdd016e4d05d1/python/mypy/issues/9393 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c61ae09299c4744e454f553589d7c946cb42232eb5156679c36bdd016e4d05d1/python/mypy/issues/9393 |
| og:image:alt | 🚀 Feature Add support for pkgutil-style namespace packages. Pitch In october 2018, PR #5691 brought support for PEP420 namespace packages (i.e. native namespace packages), which closed issue #1645.... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | alxroyer |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7d0829bbde9e48b2486cb5dd6d147896eb01d32134627091f818958a935ef3f0 |
| 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 | f3f3a43ca095cdea3abbb394112e971f9fdb94fa |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width