File tree Expand file tree Collapse file tree 2 files changed +4
-7
lines changed Expand file tree Collapse file tree 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(
16701670 context ,
16711671 )
16721672 else :
1673+ err_code = codes .TYPPEDICT_UNKNOWN_KEY if setitem else codes .TYPEDDICT_ITEM
16731674 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
16771676 )
16781677 matches = best_matches (item_name , typ .items .keys ())
16791678 if matches :
16801679 self .note (
16811680 "Did you mean {}?" .format (pretty_seq (matches [:3 ], "or" )),
16821681 context ,
1683- code = codes . TYPEDDICT_ITEM ,
1682+ code = err_code ,
16841683 )
16851684
16861685 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):
476476 two_commonparts: int
477477
478478a: 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]
482480not_exist = a['not_exist'] # type: ignore[typeddict-item]
483481[builtins fixtures/dict.pyi]
484482[typing fixtures/typing-typeddict.pyi]
You can’t perform that action at this time.
0 commit comments