Skip to content

Commit ee2bef4

Browse files
authored
handle TypeVarTuple and ParamSpec for PEP 695 (#799)
1 parent fad8ffb commit ee2bef4

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

pyflakes/checker.py

+2
Original file line numberDiff line numberDiff line change
@@ -2192,6 +2192,8 @@ def TYPEVAR(self, node):
21922192
self.handleNodeStore(node)
21932193
self.handle_annotation_always_deferred(node.bound, node)
21942194

2195+
PARAMSPEC = TYPEVARTUPLE = handleNodeStore
2196+
21952197
def TYPEALIAS(self, node):
21962198
self.handleNode(node.name, node)
21972199
with self._type_param_scope(node):

pyflakes/test/test_type_annotations.py

+17
Original file line numberDiff line numberDiff line change
@@ -780,3 +780,20 @@ class C[T](list[T]): pass
780780
781781
T # not accessible afterwards
782782
""", m.UndefinedName, m.UndefinedName)
783+
784+
@skipIf(version_info < (3, 12), 'new in Python 3.12')
785+
def test_type_parameters_TypeVarTuple(self):
786+
self.flakes("""
787+
def f[*T](*args: *T) -> None: ...
788+
""")
789+
790+
@skipIf(version_info < (3, 12), 'new in Python 3.12')
791+
def test_type_parameters_ParamSpec(self):
792+
self.flakes("""
793+
from typing import Callable
794+
795+
def f[R, **P](f: Callable[P, R]) -> Callable[P, R]:
796+
def g(*args: P.args, **kwargs: P.kwargs) -> R:
797+
return f(*args, **kwargs)
798+
return g
799+
""")

0 commit comments

Comments
 (0)