Skip to content

Commit

Permalink
Enable TypedDict vs overload interaction that was disabled (#7365)
Browse files Browse the repository at this point in the history
I think this can be re-enabled since #5198 was fixed.
  • Loading branch information
ilevkivskyi authored Aug 18, 2019
1 parent 2e1d7e6 commit 9bc4317
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
4 changes: 1 addition & 3 deletions mypy/checkexpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -1437,9 +1437,7 @@ def plausible_overload_call_targets(self,
order."""

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

matches = [] # type: List[CallableType]
Expand Down
6 changes: 2 additions & 4 deletions test-data/unit/check-overloading.test
Original file line number Diff line number Diff line change
Expand Up @@ -2551,11 +2551,9 @@ reveal_type(f(**{'x': 4, 'y': 4})) # N: Revealed type is 'builtins.tup
reveal_type(f(**{'a': 4, 'b': 4, 'c': 4})) # N: Revealed type is 'builtins.tuple[builtins.int]'
[builtins fixtures/dict.pyi]

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

0 comments on commit 9bc4317

Please sign in to comment.