Skip to content
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
3 changes: 2 additions & 1 deletion mypy/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -2989,8 +2989,9 @@ def _real_quick_ratio(a: str, b: str) -> float:


def best_matches(current: str, options: Collection[str], n: int) -> list[str]:
if not current:
return []
# narrow down options cheaply
assert current
options = [o for o in options if _real_quick_ratio(current, o) > 0.75]
if len(options) >= 50:
options = [o for o in options if abs(len(o) - len(current)) <= 1]
Expand Down
12 changes: 12 additions & 0 deletions test-data/unit/check-typeddict.test
Original file line number Diff line number Diff line change
Expand Up @@ -2873,3 +2873,15 @@ foo({"foo": {"e": "foo"}}) # E: Type of TypedDict is ambiguous, none of ("A", "
# E: Argument 1 to "foo" has incompatible type "Dict[str, Dict[str, str]]"; expected "Union[A, B]"
[builtins fixtures/dict.pyi]
[typing fixtures/typing-typeddict.pyi]

[case testTypedDictMissingEmptyKey]
from typing_extensions import TypedDict

class A(TypedDict):
my_attr_1: str
my_attr_2: int

d: A
d[''] # E: TypedDict "A" has no key ""
[builtins fixtures/dict.pyi]
[typing fixtures/typing-typeddict.pyi]