Bug Report
isinstance throws Parameterized generics cannot be used with class or instance checks [misc] for TypeAlias for a class inherited from NamedTuple. This is related to #18488
To Reproduce
from typing import Any, TypeAlias, NamedTuple
class Foo(NamedTuple):
pass
Alias: TypeAlias = Foo
def is_foo(x: Any) -> bool:
return isinstance(x, Alias)
https://mypy-play.net//?mypy=latest&python=3.13&gist=91206dbc88693a2e88ec03e79a8d8235
Expected Behavior
Should not throw.
Actual Behavior
Throws Parameterized generics cannot be used with class or instance checks [misc]
- Mypy version used: 1.19.1
- Mypy command-line flags:
mypy . --strict
- Mypy configuration options from
pyproject.toml:
[tool.mypy]
strict = true
allow_redefinition = true
allow_redefinition_new = true
local_partial_types = true
follow_untyped_imports = true
- Python version used: 3.13.11
Bug Report
isinstancethrowsParameterized generics cannot be used with class or instance checks [misc]forTypeAliasfor a class inherited fromNamedTuple. This is related to #18488To Reproduce
https://mypy-play.net//?mypy=latest&python=3.13&gist=91206dbc88693a2e88ec03e79a8d8235
Expected Behavior
Should not throw.
Actual Behavior
Throws
Parameterized generics cannot be used with class or instance checks [misc]mypy . --strictpyproject.toml: