Closed as duplicate of#18692
Description
Bug Report
Follow-up after #18850 discovery.
When a base TypedDict
is defined in sys.version_info
branches, mypy
does not pick it as a proper TypedDict
base.
To Reproduce
from typing import Required, TypedDict
class Base(TypedDict):
foo: int
BestBase = Base
class Child(BestBase):
baz: Required[int] # E: Required[] can be only used in a TypedDict definition
Or playground
Expected Behavior
sys.version_info
is a recognized guard, so Child
should be treated as regular TypedDict
.
Actual Behavior
e.py:9: error: Required[] can be only used in a TypedDict definition [valid-type]
Found 1 error in 1 file (checked 1 source file)
Your Environment
- Mypy version used: 1.15.0 and current master
- Mypy command-line flags: N/A
- Mypy configuration options from
mypy.ini
(and other config files): N/A - Python version used: 3.12