Skip to content

Enable TypedDict vs overload interaction that was disabled #7365

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, 2019
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
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