File tree 2 files changed +4
-7
lines changed 2 files changed +4
-7
lines changed Original file line number Diff line number Diff line change @@ -1670,17 +1670,16 @@ def typeddict_key_not_found(
1670
1670
context ,
1671
1671
)
1672
1672
else :
1673
+ err_code = codes .TYPPEDICT_UNKNOWN_KEY if setitem else codes .TYPEDDICT_ITEM
1673
1674
self .fail (
1674
- f'TypedDict { format_type (typ )} has no key "{ item_name } "' ,
1675
- context ,
1676
- code = codes .TYPPEDICT_UNKNOWN_KEY if setitem else codes .TYPEDDICT_ITEM ,
1675
+ f'TypedDict { format_type (typ )} has no key "{ item_name } "' , context , code = err_code
1677
1676
)
1678
1677
matches = best_matches (item_name , typ .items .keys ())
1679
1678
if matches :
1680
1679
self .note (
1681
1680
"Did you mean {}?" .format (pretty_seq (matches [:3 ], "or" )),
1682
1681
context ,
1683
- code = codes . TYPEDDICT_ITEM ,
1682
+ code = err_code ,
1684
1683
)
1685
1684
1686
1685
def typeddict_context_ambiguous (self , types : list [TypedDictType ], context : Context ) -> None :
Original file line number Diff line number Diff line change @@ -476,9 +476,7 @@ class A(TypedDict):
476
476
two_commonparts: int
477
477
478
478
a: A = {'one_commonpart': 1, 'two_commonparts': 2}
479
- a['other_commonpart'] = 3 # type: ignore[typeddict-unknown-key] \
480
- # N: Did you mean "one_commonpart" or "two_commonparts"? \
481
- # N: Error code "typeddict-item" not covered by "type: ignore" comment
479
+ a['other_commonpart'] = 3 # type: ignore[typeddict-unknown-key]
482
480
not_exist = a['not_exist'] # type: ignore[typeddict-item]
483
481
[builtins fixtures/dict.pyi]
484
482
[typing fixtures/typing-typeddict.pyi]
You can’t perform that action at this time.
0 commit comments