8000 Admit that **kwargs mapping subtypes may have no direct type parameters by sterliakov · Pull Request #18850 · python/mypy · GitHub
[go: up one dir, main page]

Skip to content

Admit that **kwargs mapping subtypes may have no direct type parameters #18850

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
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
6 changes: 2 additions & 4 deletions mypy/argmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,8 @@ def expand_actual_type(
formal_name = (set(actual_type.items.keys()) - self.kwargs_used).pop()
self.kwargs_used.add(formal_name)
return actual_type.items[formal_name]
elif (
isinstance(actual_type, Instance)
and len(actual_type.args) > 1
and is_subtype(actual_type, self.context.mapping_type)
elif isinstance(actual_type, Instance) and is_subtype(
actual_type, self.context.mapping_type
):
# Only `Mapping` type can be unpacked with `**`.
# Other types will produce an error somewhere else.
Expand Down
2 changes: 1 addition & 1 deletion test-data/unit/check-kwargs.test
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ from typing import Mapping
class MappingSubclass(Mapping[str, str]): pass
def f(**kwargs: 'A') -> None: pass
d: MappingSubclass
f(**d)
f(**d) # E: Argument 1 to "f" has incompatible type "**MappingSubclass"; expected "A"
class A: pass
[builtins fixtures/dict.pyi]

Expand Down
0