local stubs folder makes mypy think an unrelated `module.__init__` duplicates `module`
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
Bug Report
Having a local stubs folder makes mypy think an unrelated module.__init__ duplicates module.
Deleting the __init__.pyi in the local stubs solves the issue, but will cause many more issues where mypy thinks the package can't be imported.
This happens with or without explicit_package_bases.
To Reproduce
MRE: reproduction.zip
Expected Behavior
No error or some way to work around this issue
Actual Behavior
my_package\_dynamic\__init__.py: error: Source file found twice under different module names: "my_package._dynamic" and "my_package._dynamic.__init__"
my_package\_dynamic\__init__.py: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#mapping-file-paths-to-modules for more info
my_package\_dynamic\__init__.py: note: Common resolutions include: a) adding `__init__.py` somewhere, b) using `--explicit-package-bases` or adjusting MYPYPATH
Found 1 error in 1 file (errors prevented further checking)
Your Environment
- Mypy version used: mypy 1.15.0 (compiled: yes)
- Mypy command-line flags:
python3.13 -m mypy . - Mypy configuration options from
mypy.ini(and other config files): (see MRE) - Python version used: Python 3.13.0
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
Start by unpacking reproduction.zip and running python3.13 -m mypy . with the included configuration and local stubs. Trace the module-path handling that reports both my_package._dynamic and my_package._dynamic.__init__; done means the duplicate-module error is avoided without making the stubs package unimportable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100