Closed as not planned
Description
The following is a simplification of pytest’s conftest.py
scenario, but can be reproduced fairly simply — it boils down to checking files (modules) with the same name in different folders with a single mypy
invocation:
(.venv) > mkdir test
(.venv) > mkdir test/foo
(.venv) > mkdir test/bar
(.venv) > touch test/foo/same.py
(.venv) > touch test/bar/same.py
(.venv) > mypy test/foo/same.py
Success: no issues found in 1 source file
(.venv) > mypy test/bar/same.py
Success: no issues found in 1 source file
However, checking both files together causes the following error:
(.venv) > mypy test/foo/same.py test/bar/same.py
test/bar/same.py: error: Duplicate module named "same" (also at "test/foo/same.py")
test/bar/same.py: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#mapping-file-paths-to-modules for more info
test/bar/same.py: note: Common resolutions include: a) using `--exclude` to avoid checking one of them, b) adding `__init__.py` somewhere, c) using `--explicit-package-bases` or adjusting MYPYPATH
Found 1 error in 1 file (errors prevented further checking)
(.venv) > mypy test/
test/foo/same.py: error: Duplicate module named "same" (also at "test/bar/same.py")
test/foo/same.py: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#mapping-file-paths-to-modules for more info
test/foo/same.py: note: Common resolutions include: a) using `--exclude` to avoid checking one of them, b) adding `__init__.py` somewhere, c) using `--explicit-package-bases` or adjusting MYPYPATH
Found 1 error in 1 file (errors prevented further checking)
I don’t really want to add __init__.py
files to turn these folders into (sub)packages, because they’re simply independent files.
To Reproduce
See above.
Expected Behavior
That mypy
checks both files and succeeds.
Actual Behavior
Above error.
Your Environment
- Mypy version used:
mypy 1.6.1 (compiled: yes)
- Mypy command-line flags: none
- Mypy configuration options from
mypy.ini
(and other config files): none - Python version used:
Python 3.11.6 (main, Oct 2 2023, 17:45:58) [Clang 14.0.3 (clang-1403.0.22.14.1)] on darwin