mypy
mypy copied to clipboard
module name assumed is __main__ for .pyw files on windows
Bug Report
On windows, .pyw is a valid extension for Python files (to be executed by pythonw.exe).
mypy however assumes files with .pyw extension to have module name __main__.
This results in a False negative when 2 or more .pyw files are checked by mypy.
To Reproduce
Have mypy check 2 or more files with .pyw extension on windows.
Expected Behavior
No mypy issue.
Actual Behavior
application_2.pyw: error: Duplicate module named "__main__" (also at "application_1.pyw")
application_2.pyw: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#mapping-file-paths-to-modules for more info
application_2.pyw: 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)
Your Environment
Python 3.12.5 mypy==1.11.1 mypy-extensions==1.0.0 typing_extensions==4.12.2
Please run the attached windows batch file to reproduce.