# test.py
from typing import Generic, Type, TypedDict, TypeVar
_TA = TypeVar("_TA")
_TB = TypeVar("_TB")
class GenericBase(Generic[_TA, _TB]):
type_a: Type[_TA]
type_b: Type[_TB]
A = TypedDict("A", {})
B = TypedDict("B", {})
class GenericChild(GenericBase[A, B]):
type_a = A
type_b = B
https://mypy-play.net/?mypy=latest&python=3.10&gist=6223ebcaa996d172199c2ba03b3b677f
I think I found a bug when using TypedDict as a generic argument, unless I'm missing something the code above should type check, and it does on pyright, but mypy returns a weird error message.
$ mypy test.py
test.py:21: error: Incompatible types in assignment (expression has type "Type[A]", base class "GenericBase" defined the type as "Type[A]")
test.py:22: error: Incompatible types in assignment (expression has type "Type[B]", base class "GenericBase" defined the type as "Type[B]")
Found 2 errors in 1 file (checked 1 source file)
$ npx pyright test.py
No configuration file found.
Assuming Python platform Darwin
Searching for source files
Found 1 source file
0 errors, 0 warnings, 0 informations
Completed in 0.453sec
Your Environment
- Mypy version used: 0.941
- Mypy command-line flags: None
- Mypy configuration options from
mypy.ini (and other config files): None
- Python version used: 3.9.9
- Operating system and version: MacOS 12.1 (21C52) [Apple Silicon]
https://mypy-play.net/?mypy=latest&python=3.10&gist=6223ebcaa996d172199c2ba03b3b677f
I think I found a bug when using
TypedDictas a generic argument, unless I'm missing something the code above should type check, and it does on pyright, but mypy returns a weird error message.Your Environment
mypy.ini(and other config files): None