Skip to content

Commit 7b74e82

Browse files
authored
Merge pull request #183 from snok/pep646-starred-unpack
feat: Add support for PEP646 syntax for unpacking `TypeVarTuple`
2 parents ccf886e + 87c0876 commit 7b74e82

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

flake8_type_checking/checker.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ def visit(self, node: ast.AST) -> None:
101101
elif isinstance(node, (ast.Tuple, ast.List)):
102102
for n in node.elts:
103103
self.visit(n)
104+
elif isinstance(node, ast.Starred) and isinstance(node.ctx, ast.Load):
105+
self.visit(node.value)
104106
elif isinstance(node, ast.Constant) and isinstance(node.value, str):
105107
self.visit_annotation_string(node)
106108
elif isinstance(node, ast.Name):

tests/test_tc200.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,20 @@ class FooDict(TypedDict):
128128
),
129129
]
130130

131+
if sys.version_info >= (3, 11):
132+
# PEP646 tests
133+
examples += [
134+
(
135+
textwrap.dedent("""
136+
if TYPE_CHECKING:
137+
Ts = TypeVarTuple("Ts")
138+
139+
x: tuple[*Ts]
140+
"""),
141+
{'5:10 ' + TC200.format(annotation='Ts')},
142+
)
143+
]
144+
131145
if sys.version_info >= (3, 12):
132146
# PEP695 tests
133147
examples += [

0 commit comments

Comments
 (0)