Skip to content

Commit 6badb4a

Browse files
authored
Admit that **kwargs mapping subtypes may have no direct type parameters (#18850)
Fixes #13675. I don't know why this check was ever needed (since #11151), but it doesn't seem correct.
1 parent 4b1a255 commit 6badb4a

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

mypy/argmap.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,10 +249,8 @@ def expand_actual_type(
249249
formal_name = (set(actual_type.items.keys()) - self.kwargs_used).pop()
250250
self.kwargs_used.add(formal_name)
251251
return actual_type.items[formal_name]
252-
elif (
253-
isinstance(actual_type, Instance)
254-
and len(actual_type.args) > 1
255-
and is_subtype(actual_type, self.context.mapping_type)
252+
elif isinstance(actual_type, Instance) and is_subtype(
253+
actual_type, self.context.mapping_type
256254
):
257255
# Only `Mapping` type can be unpacked with `**`.
258256
# Other types will produce an error somewhere else.

test-data/unit/check-kwargs.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ from typing import Mapping
345345
class MappingSubclass(Mapping[str, str]): pass
346346
def f(**kwargs: 'A') -> None: pass
347347
d: MappingSubclass
348-
f(**d)
348+
f(**d) # E: Argument 1 to "f" has incompatible type "**MappingSubclass"; expected "A"
349349
class A: pass
350350
[builtins fixtures/dict.pyi]
351351

0 commit comments

Comments
 (0)