summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Sottile <asottile@umich.edu>2022-05-30 12:25:29 -0400
committerGitHub <noreply@github.com>2022-05-30 12:25:29 -0400
commit2a61f3c0a1dddb00453c66d1fa9f45d7b5b7897d (patch)
tree6ae8996753f1c2660d0119cb4f9ef903cae01762
parente02336c3d47c621feed730f5bdaa792babca75be (diff)
downloadpyflakes-2a61f3c0a1dddb00453c66d1fa9f45d7b5b7897d.tar.gz
add tests for python3.11-specific syntax (#694)
-rw-r--r--.github/workflows/test.yml2
-rw-r--r--pyflakes/checker.py2
-rw-r--r--pyflakes/test/test_other.py9
-rw-r--r--pyflakes/test/test_type_annotations.py15
4 files changed, 26 insertions, 2 deletions
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index c10d012..54f1494 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -12,7 +12,7 @@ jobs:
strategy:
fail-fast: false
matrix:
- python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "pypy-3.7"]
+ python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11.0-beta - 3.11.999", "pypy-3.7"]
os: [ubuntu-latest]
# Include minimum py3 + maximum py3 + pypy3 on Windows
include:
diff --git a/pyflakes/checker.py b/pyflakes/checker.py
index 0c3f66e..c89bba9 100644
--- a/pyflakes/checker.py
+++ b/pyflakes/checker.py
@@ -2346,7 +2346,7 @@ class Checker(object):
# Process the other nodes: "except:", "else:", "finally:"
self.handleChildren(node, omit='body')
- TRYEXCEPT = TRY
+ TRYEXCEPT = TRYSTAR = TRY
def EXCEPTHANDLER(self, node):
if PY2 or node.name is None:
diff --git a/pyflakes/test/test_other.py b/pyflakes/test/test_other.py
index efbc75d..97685ef 100644
--- a/pyflakes/test/test_other.py
+++ b/pyflakes/test/test_other.py
@@ -1668,6 +1668,15 @@ class TestUnusedAssignment(TestCase):
except Exception as e: pass
''', m.UnusedVariable)
+ @skipIf(version_info < (3, 11), 'new in Python 3.11')
+ def test_exception_unused_in_except_star(self):
+ self.flakes('''
+ try:
+ pass
+ except* OSError as e:
+ pass
+ ''', m.UnusedVariable)
+
def test_exceptionUnusedInExceptInFunction(self):
self.flakes('''
def download_review():
diff --git a/pyflakes/test/test_type_annotations.py b/pyflakes/test/test_type_annotations.py
index 3b6d5e7..1caecb4 100644
--- a/pyflakes/test/test_type_annotations.py
+++ b/pyflakes/test/test_type_annotations.py
@@ -801,3 +801,18 @@ class TestTypeAnnotations(TestCase):
class Y(NamedTuple):
y: NamedTuple("v", [("vv", int)])
""")
+
+ @skipIf(version_info < (3, 11), 'new in Python 3.11')
+ def test_variadic_generics(self):
+ self.flakes("""
+ from typing import Generic
+ from typing import TypeVarTuple
+
+ Ts = TypeVarTuple('Ts')
+
+ class Shape(Generic[*Ts]): pass
+
+ def f(*args: *Ts) -> None: ...
+
+ def g(x: Shape[*Ts]) -> Shape[*Ts]: ...
+ """)