Skip to content
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
3 changes: 2 additions & 1 deletion mypy/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@
TypeTranslator,
TypeType,
TypeVarId,
TypeVarLikeType,
TypeVarType,
UnboundType,
UninhabitedType,
Expand Down Expand Up @@ -3161,7 +3162,7 @@ def check_multi_assignment(
# TODO: maybe elsewhere; redundant.
rvalue_type = get_proper_type(rv_type or self.expr_checker.accept(rvalue))

if isinstance(rvalue_type, TypeVarType):
if isinstance(rvalue_type, TypeVarLikeType):
rvalue_type = get_proper_type(rvalue_type.upper_bound)

if isinstance(rvalue_type, UnionType):
Expand Down
20 changes: 20 additions & 0 deletions test-data/unit/check-parameter-specification.test
Original file line number Diff line number Diff line change
Expand Up @@ -1092,3 +1092,23 @@ def func(callback: Callable[P, str]) -> Callable[P, str]:
return 'baz'
return inner
[builtins fixtures/paramspec.pyi]

[case testUnpackingParamsSpecArgsAndKwargs]
from typing import Callable
from typing_extensions import ParamSpec

P = ParamSpec("P")

def func(callback: Callable[P, str]) -> Callable[P, str]:
def inner(*args: P.args, **kwargs: P.kwargs) -> str:
a, *b = args
Comment thread
AlexWaygood marked this conversation as resolved.
reveal_type(a) # N: Revealed type is "builtins.object"
reveal_type(b) # N: Revealed type is "builtins.list[builtins.object]"
c, *d = kwargs
reveal_type(c) # N: Revealed type is "builtins.str"
reveal_type(d) # N: Revealed type is "builtins.list[builtins.str]"
e = {**kwargs}
reveal_type(e) # N: Revealed type is "builtins.dict[builtins.str, builtins.object]"
return "foo"
return inner
[builtins fixtures/paramspec.pyi]