Skip to content

Commit 9bc4317

Browse files
authored
Enable TypedDict vs overload interaction that was disabled (python#7365)
I think this can be re-enabled since python#5198 was fixed.
1 parent 2e1d7e6 commit 9bc4317

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

mypy/checkexpr.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -1437,9 +1437,7 @@ def plausible_overload_call_targets(self,
14371437
order."""
14381438

14391439
def has_shape(typ: Type) -> bool:
1440-
# TODO: Once https://github.com/python/mypy/issues/5198 is fixed,
1441-
# add 'isinstance(typ, TypedDictType)' somewhere below.
1442-
return (isinstance(typ, TupleType)
1440+
return (isinstance(typ, TupleType) or isinstance(typ, TypedDictType)
14431441
or (isinstance(typ, Instance) and typ.type.is_named_tuple))
14441442

14451443
matches = [] # type: List[CallableType]

test-data/unit/check-overloading.test

+2-4
Original file line numberDiff line numberDiff line change
@@ -2551,11 +2551,9 @@ reveal_type(f(**{'x': 4, 'y': 4})) # N: Revealed type is 'builtins.tup
25512551
reveal_type(f(**{'a': 4, 'b': 4, 'c': 4})) # N: Revealed type is 'builtins.tuple[builtins.int]'
25522552
[builtins fixtures/dict.pyi]
25532553

2554-
[case testOverloadKwargsSelectionWithTypedDict-skip]
2555-
# TODO: Mypy doesn't seem to correctly destructure typed dicts in general.
2556-
# We should re-enable this once https://github.com/python/mypy/issues/5198 is resolved
2554+
[case testOverloadKwargsSelectionWithTypedDict]
25572555
from typing import overload, Tuple
2558-
from mypy_extensions import TypedDict
2556+
from typing_extensions import TypedDict
25592557
@overload
25602558
def f(*, x: int) -> Tuple[int]: ...
25612559
@overload

0 commit comments

Comments
 (0)