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
TypedDict-based recursive type is flagged as invalid when defined using functional syntax while no issue is reported for analogous class-based definition.
Also no issue is reported when the recursive property is defined using some of the special forms (like Required, Optional etc) instead of List. The following code passes typecheck without errors:
Fixes#14460
Recursive TypedDicts/NamedTuples defined with call syntax that have item
types that look like type applications suffer the same chicken-and-egg
problem that recursive type aliases. Fortunately, there is a very simple
way to distinguish them without fully analyzing rvalues, this is what
this PR does.
Bug Report
TypedDict
-based recursive type is flagged as invalid when defined using functional syntax while no issue is reported for analogous class-based definition.To Reproduce
Expected Behavior
TypedDict
-based recursive types to have similar behaviour when defined using class/functional syntax.Actual Behavior
results in an error:
while similar type defined as a class has no issues reported:
Also no issue is reported when the recursive property is defined using some of the special forms (like
Required
,Optional
etc) instead ofList
. The following code passes typecheck without errors:Your Environment
mypy 0.991 (compiled: yes)
none
mypy.ini
(and other config files):none
3.11.1
The text was updated successfully, but these errors were encountered: