Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
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 4 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
19 changes: 19 additions & 0 deletions 19 test-data/unit/check-typevar-tuple.test
Original file line number Diff line number Diff line change
Expand Up @@ -2921,3 +2921,22 @@ def g(x: K) -> None:
assert d is not None
reveal_type(d) # N: Revealed type is "tuple[K | list[int], ...] | tuple[*tuple[int | list[int], ...], int]"
[builtins fixtures/tuple.pyi]

[case testTypeVarTupleUnpackVarWithConstrainedTypeVarExpansion]
# Regression test for https://github.com/python/mypy/issues/21693
from typing import Generic, Tuple, TypeVar
from typing_extensions import Literal, TypeVarTuple, Unpack

T = TypeVar("T")
P = TypeVar("P", Literal[True], Literal[False])
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
Morty Proxy This is a proxified and sanitized view of the page, visit original site.