Skip to content

Commit

Permalink
Merge pull request #183 from snok/pep646-starred-unpack
Browse files Browse the repository at this point in the history
feat: Add support for PEP646 syntax for unpacking `TypeVarTuple`
  • Loading branch information
Daverball committed Jan 29, 2024
2 parents ccf886e + 87c0876 commit 7b74e82
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions flake8_type_checking/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ def visit(self, node: ast.AST) -> None:
elif isinstance(node, (ast.Tuple, ast.List)):
for n in node.elts:
self.visit(n)
elif isinstance(node, ast.Starred) and isinstance(node.ctx, ast.Load):
self.visit(node.value)
elif isinstance(node, ast.Constant) and isinstance(node.value, str):
self.visit_annotation_string(node)
elif isinstance(node, ast.Name):
Expand Down
14 changes: 14 additions & 0 deletions tests/test_tc200.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,20 @@ class FooDict(TypedDict):
),
]

if sys.version_info >= (3, 11):
# PEP646 tests
examples += [
(
textwrap.dedent("""
if TYPE_CHECKING:
Ts = TypeVarTuple("Ts")
x: tuple[*Ts]
"""),
{'5:10 ' + TC200.format(annotation='Ts')},
)
]

if sys.version_info >= (3, 12):
# PEP695 tests
examples += [
Expand Down

0 comments on commit 7b74e82

Please sign in to comment.