-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Namespace packages problem with typestubs #13998
Labels
bug
mypy got something wrong
Comments
Does it reproduce without the mypy plugins? |
Yes, it does |
Python 3.10.1 LogTRACE: Looking for posixpath at posixpath.meta.json
LOG: Could not load cache for posixpath: posixpath.meta.json
LOG: Metadata not found for posixpath
LOG: Parsing /home/user/project/.env/lib/python3.10/site-packages/mypy/typeshed/stdlib/posixpath.pyi (posixpath)
TRACE: Looking for pkg2.anotherapp.constants at pkg2/anotherapp/constants.meta.json
LOG: Could not load cache for pkg2.anotherapp.constants: pkg2/anotherapp/constants.meta.json
LOG: Metadata not found for pkg2.anotherapp.constants
LOG: Parsing /home/user/project/src/pkg2/anotherapp/constants.py (pkg2.anotherapp.constants)
TRACE: Looking for project.mypkg.impersonation at project/mypkg/impersonation.meta.json
LOG: Could not load cache for project.mypkg.impersonation: project/mypkg/impersonation.meta.json
LOG: Metadata not found for project.mypkg.impersonation
LOG: Parsing /home/user/project/src/project/mypkg/impersonation.py (project.mypkg.impersonation)
TRACE: Looking for faker.factory at faker/factory.meta.json
LOG: Could not load cache for faker.factory: faker/factory.meta.json
LOG: Metadata not found for faker.factory
LOG: Parsing /home/user/project/.env/lib/python3.10/site-packages/faker/factory.py (faker.factory)
TRACE: Looking for faker.generator at faker/generator.meta.json
LOG: Could not load cache for faker.generator: faker/generator.meta.json
LOG: Metadata not found for faker.generator
LOG: Parsing /home/user/project/.env/lib/python3.10/site-packages/faker/generator.py (faker.generator)
TRACE: Looking for faker.proxy at faker/proxy.meta.json
LOG: Could not load cache for faker.proxy: faker/proxy.meta.json
LOG: Metadata not found for faker.proxy
LOG: Parsing /home/user/project/.env/lib/python3.10/site-packages/faker/proxy.py (faker.proxy)
TRACE: Looking for freezegun.api at freezegun/api.meta.json
LOG: Could not load cache for freezegun.api: freezegun/api.meta.json
LOG: Metadata not found for freezegun.api
LOG: Parsing /home/user/project/.env/lib/python3.10/site-packages/freezegun/api.pyi (freezegun.api)
TRACE: Looking for pytest_mock.plugin at pytest_mock/plugin.meta.json
LOG: Could not load cache for pytest_mock.plugin: pytest_mock/plugin.meta.json
LOG: Metadata not found for pytest_mock.plugin
LOG: Parsing /home/user/project/.env/lib/python3.10/site-packages/pytest_mock/plugin.py (pytest_mock.plugin)
TRACE: Looking for mypy.typeshed.stdlib.unittest.mock at mypy/typeshed/stdlib/unittest/mock.meta.json
LOG: Could not load cache for mypy.typeshed.stdlib.unittest.mock: mypy/typeshed/stdlib/unittest/mock.meta.json
LOG: Metadata not found for mypy.typeshed.stdlib.unittest.mock
LOG: Parsing /home/user/project/.env/lib/python3.10/site-packages/mypy/typeshed/stdlib/unittest/mock.pyi (mypy.typeshed.stdlib.unittest.mock)
TRACE: Looking for urllib3.util.url at urllib3/util/url.meta.json
LOG: Could not load cache for urllib3.util.url: urllib3/util/url.meta.json
LOG: Metadata not found for urllib3.util.url
LOG: Parsing /home/user/project/.env/lib/python3.10/site-packages/urllib3-stubs/util/url.pyi (urllib3.util.url)
TRACE: Looking for http.client at http/client.meta.json
LOG: Could not load cache for http.client: http/client.meta.json
LOG: Metadata not found for http.client
LOG: Parsing /home/user/project/.env/lib/python3.10/site-packages/mypy/typeshed/stdlib/http/client.pyi (http.client)
TRACE: Looking for requests.adapters at requests/adapters.meta.json
LOG: Could not load cache for requests.adapters: requests/adapters.meta.json
LOG: Metadata not found for requests.adapters
LOG: Parsing /home/user/project/.env/lib/python3.10/site-packages/requests-stubs/adapters.pyi (requests.adapters)
TRACE: Looking for responses.matchers at responses/matchers.meta.json
LOG: Could not load cache for responses.matchers: responses/matchers.meta.json
LOG: Metadata not found for responses.matchers
LOG: Parsing /home/user/project/.env/lib/python3.10/site-packages/responses/matchers.py (responses.matchers)
TRACE: Looking for responses.registries at responses/registries.meta.json
LOG: Could not load cache for responses.registries: responses/registries.meta.json
LOG: Metadata not found for responses.registries
LOG: Parsing /home/user/project/.env/lib/python3.10/site-packages/responses/registries.py (responses.registries)
TRACE: Looking for urllib3.response at urllib3/response.meta.json
LOG: Could not load cache for urllib3.response: urllib3/response.meta.json
LOG: Metadata not found for urllib3.response
LOG: Parsing /home/user/project/.env/lib/python3.10/site-packages/urllib3-stubs/response.pyi (urllib3.response)
TRACE: Looking for unittest.mock at unittest/mock.meta.json
LOG: Could not load cache for unittest.mock: unittest/mock.meta.json
LOG: Metadata not found for unittest.mock
LOG: Parsing /home/user/project/.env/lib/python3.10/site-packages/mypy/typeshed/stdlib/unittest/mock.pyi (unittest.mock)
LOG: Build finished in 1.181 seconds with 622 modules, and 1 errors
.env/lib/python3.10/site-packages/mypy/typeshed/stdlib/unittest/mock.pyi: error: Source file found twice under different module names: "mypy.typeshed.stdlib.unittest.mock" and "unittest.mock" Third party libraries
The trace mentions Internal usageIn my code, I have imports from from unittest import mock And also: from unittest.mock import patch |
I've traced this back to getsentry/responses#556, updating to |
Oh lol, wow that would explain it |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bug Report
I'm experiencing a weird issue where enabling
--namespace-packages
triggers mypy to complain about theunittest.mock
package. It works fine without--namespace-packages
(except, you know, namespace packages don't work).To Reproduce
I haven't been able to reproduce this outside of our project yet (which is not open-source). It's a fairly large Django project.
I'm hoping someone can point me in the direction where things are going wrong so I can dig deeper to figure out what's going wrong.
Expected Behavior
Mypy should not complain about stubs
Actual Behavior
Mypy exits with an error.
Your Environment
0.982
--namespace-packages
mypy.ini
(and other config files):3.10.8
The text was updated successfully, but these errors were encountered: