You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When instantiating a typeddict that was created as a class variable without any type hints and which has a not-required key, mypy thinks that all keys are required ignoring total=False and typing.NotRequired.
To Reproduce
importtypingclassDicts:
classTF(typing.TypedDict, total=False):
user_id: intclassNR(typing.TypedDict):
user_id: typing.NotRequired[int]
TotalFalse=TFTotalFalse_Annotated: type[TF] =TFTotalFalse_TypeAlias: typing.TypeAlias=TFTotalFalse_ClassVar: typing.ClassVar[type[TF]] =TFTotalFalse_ClassVar_TypeAlias: typing.ClassVar[typing.TypeAlias] =TFNotRequired=NRNotRequired_Annotated: type[NR] =NRNotRequired_TypeAlias: typing.TypeAlias=NRNotRequired_ClassVar: typing.ClassVar[type[NR]] =NRNotRequired_ClassVar_TypeAlias: typing.ClassVar[typing.TypeAlias] =NRdicts=Dicts()
dicts.TF() # no errordicts.TotalFalse() # error: Missing named argument "user_id" [call-arg]dicts.TotalFalse_Annotated() # no errordicts.TotalFalse_TypeAlias() # no errordicts.TotalFalse_ClassVar() # no errordicts.TotalFalse_ClassVar_TypeAlias() # no errordicts.NR() # no errordicts.NotRequired() # error: Missing named argument "user_id" [call-arg]dicts.NotRequired_Annotated() # no errordicts.NotRequired_TypeAlias() # no errordicts.NotRequired_ClassVar() # no errordicts.NotRequired_ClassVar_TypeAlias() # no error
Expected Behavior
No errors
Actual Behavior
main.py:25: error: Missing named argument "user_id" [call-arg]
main.py:32: error: Missing named argument "user_id" [call-arg]
Your Environment
Mypy version used: 1.10.0
Python version used: 3.12
The text was updated successfully, but these errors were encountered:
Bug Report
When instantiating a typeddict that was created as a class variable without any type hints and which has a not-required key, mypy thinks that all keys are required ignoring
total=False
andtyping.NotRequired
.To Reproduce
Expected Behavior
No errors
Actual Behavior
main.py:25: error: Missing named argument "user_id" [call-arg]
main.py:32: error: Missing named argument "user_id" [call-arg]
Your Environment
The text was updated successfully, but these errors were encountered: