(🐞) platform specified in inline configuration results in wacky behavior
Open
Nobody has claimed this yet.
bug
topic-configuration
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
It seems like even though this is not a per module option, it is still being applied to the module, but it's using the global(linux) type defs.
import sys, winreg
if sys.platform == "win32":
winreg.QueryValueEx
# Success: no issues found in 1 source file
# mypy: platform=win32
import sys, winreg
if sys.platform == "win32":
winreg.QueryValueEx # test.py:5:5: error: Module has no attribute "QueryValueEx" [attr-defined]
- Relates to: #12342
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 with the provided mypy-play reproduction and compare how the inline # mypy: platform=win32 setting is processed with the equivalent global platform setting. Check why the module uses Linux type definitions despite the inline option; done means the guarded winreg.QueryValueEx reference is accepted with the inline setting, with a regression test covering the example.
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
- 42/100