Subscript op on TypeAlias to Enum is misinterpreted
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
Bug Report
Scanning code that makes use of an alias for an Enum class flags an error.
I see several similar issues in the GitHub issue list, e.g.
https://github.com/python/mypy/issues/14281
https://github.com/python/mypy/issues/13337
The error messages in those tickets is different however.
To Reproduce
Gist
Expected Behavior
No error
Actual Behavior
main.py:14: error: Type application targets a non-generic function or class
main.py:14: error: Variable "name" is not valid as a type
main.py:14: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
Found 2 errors in 1 file (checked 1 source file)
Your Environment
- Mypy version used: 0.971
- Mypy command-line flags: none
- Mypy configuration options from
mypy.ini(and other config files): none - Python version used: 3.6.9 (I know, I know)
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 linked Gist and reproduce the reported diagnostics using mypy 0.971, then trace how the checker resolves the Enum type alias and subscript expression. Done means the reproduction produces no error while preserving correct handling of non-generic types.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100