python / python/mypy

Unable to run mypy against installed modules

Open
#14,559 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.