Skip to content

Commit

Permalink
handle TypeVarTuple and ParamSpec for PEP 695
Browse files Browse the repository at this point in the history
  • Loading branch information
asottile committed Jan 5, 2024
1 parent fad8ffb commit 49c9f1d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pyflakes/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -2192,6 +2192,8 @@ def TYPEVAR(self, node):
self.handleNodeStore(node)
self.handle_annotation_always_deferred(node.bound, node)

PARAMSPEC = TYPEVARTUPLE = handleNodeStore

def TYPEALIAS(self, node):
self.handleNode(node.name, node)
with self._type_param_scope(node):
Expand Down
17 changes: 17 additions & 0 deletions pyflakes/test/test_type_annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -780,3 +780,20 @@ class C[T](list[T]): pass
T # not accessible afterwards
""", m.UndefinedName, m.UndefinedName)

@skipIf(version_info < (3, 12), 'new in Python 3.12')
def test_type_parameters_TypeVarTuple(self):
self.flakes("""
def f[*T](*args: *T) -> None: ...
""")

@skipIf(version_info < (3, 12), 'new in Python 3.12')
def test_type_parameters_ParamSpec(self):
self.flakes("""
from typing import Callable
def f[R, **P](f: Callable[P, R]) -> Callable[P, R]:
def g(*args: P.args, **kwargs: P.kwargs) -> R:
return f(*args, **kwargs)
return g
""")

0 comments on commit 49c9f1d

Please sign in to comment.