Skip to content
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

local stubs folder makes mypy think an unrelated module.__init__ duplicates module #18775

Open
Avasam opened this issue Mar 9, 2025 · 0 comments
Labels
bug mypy got something wrong

Comments

@Avasam
Copy link
Contributor

Avasam commented Mar 9, 2025

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
@Avasam Avasam added the bug mypy got something wrong label Mar 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

No branches or pull requests

1 participant