Not planned
Description
Bug Report
Consider the following minimal snippet:
from types import GenericAlias
from typing import get_origin
def test(expected_type: GenericAlias) -> None:
list_type = get_origin(expected_type)
list_type[int]
mypy seems to consider list_type[int]
invalid here:
$ mypy foo.py
foo.py:7: error: Value of type "type" is not indexable [index]
Found 1 error in 1 file (checked 1 source file)
To Reproduce
https://mypy-play.net/?mypy=latest&python=3.12&gist=d8185597c8fe9a327a276508cc1fa4d3
Actual Behavior
$ mypy foo.py
foo.py:7: error: Value of type "type" is not indexable [index]
Found 1 error in 1 file (checked 1 source file)
Your Environment
- Mypy version used: 1.15.0
- Mypy command-line flags: (none)
- Mypy configuration options from
mypy.ini
(and other config files): (none) - Python version used: 3.13.2
Metadata
Metadata
Assignees
Labels
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
PluginLoader
, and cover almost all of it with tests wheelnext/variantlib#27A5rocks commentedon Apr 8, 2025
I think this is moreso a typeshed thing. Probably they just need to add an overload or two?
hauntsaninja commentedon May 30, 2025
Yeah, if there is a bug here, it should be handled in typeshed. In general, static type checking of runtime typing is kind of hard to do in Python