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
I notice in the changelog that 0.990 adds support for namespace packages by default.
I've been using mypy on namespace packages (jaraco, svg, backports, and others) for some time now (jaraco/skeleton@7455f2f).
With the release of mypy 0.990, however, tests have started failing across all projects with namespace packages:
error: Source file found twice under different module names: "collections" and "jaraco.collections"
The change log indicates that 0.990 adds support for namespace packages by default. Annoyingly, this change has had the opposite effect for my projects. I find that I can restore functionality by adding explicit_package_bases = True to the config file (or equivalent command line). It's slightly annoying to have to add this configuration to all of my projects just to support some projects with namespace packages.
Is it possible that explicit package bases will become default in the future?
We chose not to make it the default at the time it was introduced because doing so was very breaking, e.g. all packages with src layout would probably break. It still remains true that most Python packages are not namespace packages, so it feels hard to justify.
(Not present in your report, but I believe the error message should currently suggest using --explicit-package-bases; let me know if that's not the case)
Correct. The suggestion wasn’t apparent when running under pytest-mypy. Once I ran the tests using mypy directly, the suggestion was present and led me to the workaround.
There seems to be a related bug in Windows where mypy is not finding the stub files (which are included in the wheel) for backports.zoneinfo in Python 3.7 and 3.8. The reproduction is pretty simple:
It may be related, but the bug as reported applies across platforms. It may be worthwhile to open a separate bug for the possibly related Windows-specific issue.
Activity
jaraco commentedon Nov 10, 2022
The reason why I ask is because in the current state, namespace packages get a second-class experience.
Apply explicit_package_bases for mypy and unpin the version. Ref pyth…
hauntsaninja commentedon Nov 10, 2022
We chose not to make it the default at the time it was introduced because doing so was very breaking, e.g. all packages with src layout would probably break. It still remains true that most Python packages are not namespace packages, so it feels hard to justify.
(Not present in your report, but I believe the error message should currently suggest using
--explicit-package-bases; let me know if that's not the case)jaraco commentedon Nov 11, 2022
Correct. The suggestion wasn’t apparent when running under pytest-mypy. Once I ran the tests using mypy directly, the suggestion was present and led me to the workaround.
pypi-jaraco.text: Autospec creation for update from version 3.10.0 to…
pypi-tempora: Autospec creation for update from version 5.0.2 to vers…
pypi-jaraco.context: Autospec creation for update from version 4.1.2 …
pypi-setuptools: Autospec creation for update from version 65.5.1 to …
pypi-zipp: Autospec creation for update from version 3.10.0 to versio…
pypi-importlib_metadata: Autospec creation for update from version 5.…
bryanforbes commentedon Dec 1, 2022
There seems to be a related bug in Windows where
mypyis not finding the stub files (which are included in the wheel) forbackports.zoneinfoin Python 3.7 and 3.8. The reproduction is pretty simple:pip install mypy backports.zoneinfo mypy -c 'from backports import zoneinfo'This only occurs on Windows. It works fine on Linux and macOS.
hauntsaninja commentedon Dec 1, 2022
@AlexWaygood interested in looking at this issue? I don't have a windows system to reproduce
AlexWaygood commentedon Dec 1, 2022
I can try to have a look, but no promises -- pretty busy at the moment :(
pypi-importlib_resources: Autospec creation for update from version 5…
pypi-keyring: Autospec creation for update from version 23.11.0 to ve…
pypi-jaraco.functools: Autospec creation for update from version 3.5.…
jaraco commentedon Mar 23, 2023
It may be related, but the bug as reported applies across platforms. It may be worthwhile to open a separate bug for the possibly related Windows-specific issue.
pypi-jaraco.collections: Autospec creation for update from version 3.…
pypi-inflect: Autospec creation for update from version 6.0.2 to vers…
Apply explicit_package_bases for mypy and unpin the version. Ref pyth…
pypi-portend: Autospec creation for update from version 3.1.0 to vers…
pypi-configparser: Autospec creation for update from version 5.3.0 to…
pypi-jaraco.classes: Autospec creation for update from version 3.2.3 …