Skip to content
Open
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: 3 additions & 1 deletion mypy/treetransform.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,9 @@ def visit_match_stmt(self, o: MatchStmt) -> MatchStmt:
)

def visit_star_expr(self, node: StarExpr) -> StarExpr:
return StarExpr(node.expr)
new = StarExpr(self.expr(node.expr))
new.valid = node.valid
return new

def visit_int_expr(self, node: IntExpr) -> IntExpr:
return IntExpr(node.value)
Expand Down
18 changes: 18 additions & 0 deletions test-data/unit/check-typevar-tuple.test
Original file line number Diff line number Diff line change
Expand Up @@ -3255,3 +3255,21 @@ class K(Base):
class Base: ...
reveal_type(K.q) # N: Revealed type is "builtins.list[tuple[builtins.bool, builtins.int, builtins.str]]"
[builtins fixtures/tuple.pyi]

[case testUnpackTypeVarTupleInFunctionWithConstrainedTypeVar]
from typing import Generic, TypeVar, Tuple
from typing_extensions import TypeVarTuple, Unpack

T = TypeVar("T")
P = TypeVar("P", int, str)
Ts = TypeVarTuple("Ts")

class Container(Generic[T, P]):
def foo(self) -> T: ...

def f(container: Container[Tuple[Unpack[Ts]], P]) -> None:
result = container.foo()
reveal_type(result) # N: Revealed type is "tuple[Unpack[Ts`-1]]"
y = (*result,)
reveal_type(y) # N: Revealed type is "tuple[Unpack[Ts`-1]]"
[builtins fixtures/tuple.pyi]
Loading