Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
64 changes: 21 additions & 43 deletions pyflakes/test/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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):
"""
Expand All @@ -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
Expand Down Expand Up @@ -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 = [
"<stdin>:1:5: Generator expression must be parenthesized",
"max(1 for i in range(10), key=lambda x: x+1)",
" ^",
]
elif PYPY:
expected_error = [
"<stdin>: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 = [
"<stdin>:1:5: Generator expression must be parenthesized",
]

expected_error = [
"<stdin>:1:5: Generator expression must be parenthesized",
"max(1 for i in range(10), key=lambda x: x+1)",
" ^",
]
self.assertEqual(errlines, expected_error)


Expand Down Expand Up @@ -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):
Expand Down
7 changes: 7 additions & 0 deletions pyflakes/test/test_type_annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
""")
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def get_long_description():
author_email="[email protected]",
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",
Expand Down