Skip to content

fix: ignore[typeddict-item] also ignore associated notes #10975

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mypy/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -1244,7 +1244,7 @@ def typeddict_key_not_found(
matches = best_matches(item_name, typ.items.keys())
if matches:
self.note("Did you mean {}?".format(
pretty_seq(matches[:3], "or")), context)
pretty_seq(matches[:3], "or")), context, code=codes.TYPEDDICT_ITEM)

def typeddict_context_ambiguous(
self,
Expand Down
11 changes: 11 additions & 0 deletions test-data/unit/check-errorcodes.test
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,17 @@ a['y'] # E: TypedDict "D" has no key "y" [typeddict-item]
[builtins fixtures/dict.pyi]
[typing fixtures/typing-typeddict.pyi]

[case testErrorCodeTypedDictNoteIgnore]
from typing_extensions import TypedDict
class A(TypedDict):
one_commonpart: int
two_commonparts: int

a: A = {'one_commonpart': 1, 'two_commonparts': 2}
a['other_commonpart'] = 3 # type: ignore[typeddict-item]
[builtins fixtures/dict.pyi]
[typing fixtures/typing-typeddict.pyi]

[case testErrorCodeCannotDetermineType]
y = x # E: Cannot determine type of "x" [has-type]
reveal_type(y) # N: Revealed type is "Any"
Expand Down