Skip to content

Commit 2105532

Browse files
authored
Ignore associated notes with ignore[typeddict-item] (#10975)
1 parent cd013d1 commit 2105532

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

mypy/messages.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1244,7 +1244,7 @@ def typeddict_key_not_found(
12441244
matches = best_matches(item_name, typ.items.keys())
12451245
if matches:
12461246
self.note("Did you mean {}?".format(
1247-
pretty_seq(matches[:3], "or")), context)
1247+
pretty_seq(matches[:3], "or")), context, code=codes.TYPEDDICT_ITEM)
12481248

12491249
def typeddict_context_ambiguous(
12501250
self,

test-data/unit/check-errorcodes.test

+11
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,17 @@ a['y'] # E: TypedDict "D" has no key "y" [typeddict-item]
472472
[builtins fixtures/dict.pyi]
473473
[typing fixtures/typing-typeddict.pyi]
474474

475+
[case testErrorCodeTypedDictNoteIgnore]
476+
from typing_extensions import TypedDict
477+
class A(TypedDict):
478+
one_commonpart: int
479+
two_commonparts: int
480+
481+
a: A = {'one_commonpart': 1, 'two_commonparts': 2}
482+
a['other_commonpart'] = 3 # type: ignore[typeddict-item]
483+
[builtins fixtures/dict.pyi]
484+
[typing fixtures/typing-typeddict.pyi]
485+
475486
[case testErrorCodeCannotDetermineType]
476487
y = x # E: Cannot determine type of "x" [has-type]
477488
reveal_type(y) # N: Revealed type is "Any"

0 commit comments

Comments
 (0)