Unable to run mypy against installed modules
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
Bug Report
I want to run mypy against an installed Python module (in my case distro_info) on Debian/Ubuntu, but all tries failed. I found no documentation about this use case.
To Reproduce
$ mypy /usr/lib/python3/dist-packages/distro_info.py
mypy: "../../usr/lib/python3/dist-packages/typing_extensions.py" shadows library module "typing_extensions"
note: A user-defined top-level module with name "typing_extensions" is not supported
$ mypy -m distro_info
mypy: can't find module 'distro_info'
$ MYPYPATH=/usr/lib/python3/dist-packages/ mypy -m distro_info
/usr/lib/python3/dist-packages is in the MYPYPATH. Please remove it.
See https://mypy.readthedocs.io/en/stable/running_mypy.html#how-mypy-handles-imports for more info
Expected Behavior
I expect that there is a way to call mypy to run against an installed module.
Your Environment
- Mypy version used: 0.991-1
- Python version used: 3.11.1-2
I can reproduce it in a minimal Debian unstable chroot after installing mypy and python3-distro-info.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the three reported commands against the installed distro_info.py module, including the MYPYPATH case, and review the running_mypy.html import-handling guidance. Trace how mypy resolves installed modules and determine whether the fix belongs in behavior or documentation; done means an installed module can be checked without the reported shadowing or module-not-found errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100