File tree 1 file changed +10
-7
lines changed
1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -1614,13 +1614,14 @@ def unexpected_typeddict_keys(
1614
1614
# Generate simpler messages for some common special cases.
1615
1615
# Use list comprehension instead of set operations to preserve order.
1616
1616
missing = [key for key in expected_keys if key not in actual_set ]
1617
- self .fail (
1618
- "Missing {} for TypedDict {}" .format (
1619
- format_key_list (missing , short = True ), format_type (typ )
1620
- ),
1621
- context ,
1622
- code = codes .TYPEDDICT_ITEM ,
1623
- )
1617
+ if missing :
1618
+ self .fail (
1619
+ "Missing {} for TypedDict {}" .format (
1620
+ format_key_list (missing , short = True ), format_type (typ )
1621
+ ),
1622
+ context ,
1623
+ code = codes .TYPEDDICT_ITEM ,
1624
+ )
1624
1625
extra = [key for key in actual_keys if key not in expected_set ]
1625
1626
if extra :
1626
1627
self .fail (
@@ -1630,6 +1631,8 @@ def unexpected_typeddict_keys(
1630
1631
context ,
1631
1632
code = codes .TYPPEDICT_UNKNOWN_KEY ,
1632
1633
)
1634
+ if missing or extra :
1635
+ # No need to check for further errors
1633
1636
return
1634
1637
found = format_key_list (actual_keys , short = True )
1635
1638
if not expected_keys :
You can’t perform that action at this time.
0 commit comments