module name assumed is __main__ for .pyw files on windows
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
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.
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 using the attached test.txt Windows batch file to reproduce the duplicate-module error with two .pyw files. Then trace mypy's file-path-to-module-name handling and add a regression test covering multiple Windows .pyw inputs; done means they no longer collide as main.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100