diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index eacd67c6..9d630de6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,12 +12,12 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.8", "3.9", "3.10", "3.11", "3.12-dev", "pypy-3.9"] + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "pypy-3.9"] os: [ubuntu-latest] # Include minimum py3 + maximum py3 + pypy3 on Windows include: - - { os: "windows-latest" , python-version: "3.8" } - - { os: "windows-latest" , python-version: "3.11" } + - { os: "windows-latest" , python-version: "3.9" } + - { os: "windows-latest" , python-version: "3.13" } - { os: "windows-latest" , python-version: "pypy-3.9" } steps: diff --git a/pyflakes/test/test_api.py b/pyflakes/test/test_api.py index ec1cbdbf..41201e4e 100644 --- a/pyflakes/test/test_api.py +++ b/pyflakes/test/test_api.py @@ -479,16 +479,12 @@ def foo(bar=baz, bax): else: msg = 'non-default argument follows default argument' - if PYPY and sys.version_info >= (3, 9): + if PYPY: column = 18 - elif PYPY: - column = 8 elif sys.version_info >= (3, 10): column = 18 - elif sys.version_info >= (3, 9): - column = 21 else: - column = 9 + column = 21 last_line = ' ' * (column - 1) + '^\n' self.assertHasErrors( sourcePath, @@ -508,23 +504,13 @@ def test_nonKeywordAfterKeywordSyntaxError(self): foo(bar=baz, bax) """ with self.makeTempFile(source) as sourcePath: - if sys.version_info >= (3, 9): - column = 17 - elif not PYPY: - column = 14 - else: - column = 13 - last_line = ' ' * (column - 1) + '^\n' - columnstr = '%d:' % column - - message = 'positional argument follows keyword argument' - + last_line = ' ' * 16 + '^\n' self.assertHasErrors( sourcePath, - ["""\ -{}:1:{} {} + [f"""\ +{sourcePath}:1:17: positional argument follows keyword argument foo(bar=baz, bax) -{}""".format(sourcePath, columnstr, message, last_line)]) +{last_line}"""]) def test_invalidEscape(self): """ @@ -533,11 +519,9 @@ def test_invalidEscape(self): # ValueError: invalid \x escape with self.makeTempFile(r"foo = '\xyz'") as sourcePath: position_end = 1 - if PYPY and sys.version_info >= (3, 9): + if PYPY: column = 7 - elif PYPY: - column = 6 - elif (3, 9) <= sys.version_info < (3, 12): + elif sys.version_info < (3, 12): column = 13 else: column = 7 @@ -669,23 +653,11 @@ def test_stdinReportsErrors(self): self.assertEqual(count, 1) errlines = err.getvalue().split("\n")[:-1] - if sys.version_info >= (3, 9): - expected_error = [ - ":1:5: Generator expression must be parenthesized", - "max(1 for i in range(10), key=lambda x: x+1)", - " ^", - ] - elif PYPY: - expected_error = [ - ":1:4: Generator expression must be parenthesized if not sole argument", # noqa: E501 - "max(1 for i in range(10), key=lambda x: x+1)", - " ^", - ] - else: - expected_error = [ - ":1:5: Generator expression must be parenthesized", - ] - + expected_error = [ + ":1:5: Generator expression must be parenthesized", + "max(1 for i in range(10), key=lambda x: x+1)", + " ^", + ] self.assertEqual(errlines, expected_error) @@ -774,8 +746,14 @@ def test_errors_syntax(self): with open(self.tempfilepath, 'wb') as fd: fd.write(b"import") d = self.runPyflakes([self.tempfilepath]) - error_msg = '{0}:1:7: invalid syntax{1}import{1} ^{1}'.format( - self.tempfilepath, os.linesep) + + if sys.version_info >= (3, 13): + message = "Expected one or more names after 'import'" + else: + message = 'invalid syntax' + + error_msg = '{0}:1:7: {1}{2}import{2} ^{2}'.format( + self.tempfilepath, message, os.linesep) self.assertEqual(d, ('', error_msg, 1)) def test_readFromStdin(self): diff --git a/pyflakes/test/test_type_annotations.py b/pyflakes/test/test_type_annotations.py index 4c8b998f..343083e7 100644 --- a/pyflakes/test/test_type_annotations.py +++ b/pyflakes/test/test_type_annotations.py @@ -797,3 +797,10 @@ def g(*args: P.args, **kwargs: P.kwargs) -> R: return f(*args, **kwargs) return g """) + + @skipIf(version_info < (3, 13), 'new in Python 3.13') + def test_type_parameter_defaults(self): + self.flakes(""" + def f[T = int](u: T) -> T: + return u + """) diff --git a/setup.py b/setup.py index 3cc2fbd9..437353fd 100755 --- a/setup.py +++ b/setup.py @@ -42,7 +42,7 @@ def get_long_description(): author_email="code-quality@python.org", url="https://github.com/PyCQA/pyflakes", packages=["pyflakes", "pyflakes.scripts", "pyflakes.test"], - python_requires='>=3.8', + python_requires='>=3.9', classifiers=[ "Development Status :: 6 - Mature", "Environment :: Console",