Skip to content

Commit fcfa2cd

Browse files
authored
Merge pull request #2001 from PyCQA/py310
py310+
2 parents d45bdc0 + 567cafc commit fcfa2cd

File tree

9 files changed

+25
-74
lines changed

9 files changed

+25
-74
lines changed

.github/workflows/main.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@ jobs:
1313
include:
1414
# linux
1515
- os: ubuntu-latest
16-
python: pypy-3.9
17-
toxenv: py
18-
- os: ubuntu-latest
19-
python: 3.9
16+
python: pypy-3.11
2017
toxenv: py
2118
- os: ubuntu-latest
2219
python: '3.10'
@@ -30,9 +27,12 @@ jobs:
3027
- os: ubuntu-latest
3128
python: '3.13'
3229
toxenv: py
30+
- os: ubuntu-latest
31+
python: '3.14'
32+
toxenv: py
3333
# windows
3434
- os: windows-latest
35-
python: 3.9
35+
python: '3.10'
3636
toxenv: py
3737
# misc
3838
- os: ubuntu-latest
@@ -46,8 +46,8 @@ jobs:
4646
toxenv: dogfood
4747
runs-on: ${{ matrix.os }}
4848
steps:
49-
- uses: actions/checkout@v2
50-
- uses: actions/setup-python@v2
49+
- uses: actions/checkout@v4
50+
- uses: actions/setup-python@v5
5151
with:
5252
python-version: ${{ matrix.python }}
5353
- run: python -mpip install --upgrade setuptools pip tox virtualenv

.pre-commit-config.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/asottile/add-trailing-comma
3-
rev: v3.2.0
3+
rev: v4.0.0
44
hooks:
55
- id: add-trailing-comma
66
- repo: https://github.com/pre-commit/pre-commit-hooks
@@ -12,23 +12,23 @@ repos:
1212
- id: trailing-whitespace
1313
exclude: ^tests/fixtures/
1414
- repo: https://github.com/asottile/setup-cfg-fmt
15-
rev: v2.8.0
15+
rev: v3.1.0
1616
hooks:
1717
- id: setup-cfg-fmt
1818
- repo: https://github.com/asottile/reorder-python-imports
19-
rev: v3.15.0
19+
rev: v3.16.0
2020
hooks:
2121
- id: reorder-python-imports
2222
args: [
2323
--application-directories, '.:src',
24-
--py39-plus,
24+
--py310-plus,
2525
--add-import, 'from __future__ import annotations',
2626
]
2727
- repo: https://github.com/asottile/pyupgrade
28-
rev: v3.20.0
28+
rev: v3.21.0
2929
hooks:
3030
- id: pyupgrade
31-
args: [--py39-plus]
31+
args: [--py310-plus]
3232
- repo: https://github.com/hhatto/autopep8
3333
rev: v2.3.2
3434
hooks:

bin/gen-pycodestyle-plugin

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ from __future__ import annotations
33

44
import inspect
55
import os.path
6+
from collections.abc import Callable
67
from collections.abc import Generator
78
from typing import Any
8-
from typing import Callable
99
from typing import NamedTuple
1010

1111
import pycodestyle

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ install_requires =
3030
mccabe>=0.7.0,<0.8.0
3131
pycodestyle>=2.14.0,<2.15.0
3232
pyflakes>=3.4.0,<3.5.0
33-
python_requires = >=3.9
33+
python_requires = >=3.10
3434
package_dir =
3535
=src
3636

src/flake8/checker.py

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -372,43 +372,6 @@ def _extract_syntax_information(exception: Exception) -> tuple[int, int]:
372372
token = ()
373373
row, column = (1, 0)
374374

375-
if (
376-
column > 0
377-
and token
378-
and isinstance(exception, SyntaxError)
379-
and len(token) == 4 # Python 3.9 or earlier
380-
):
381-
# NOTE(sigmavirus24): SyntaxErrors report 1-indexed column
382-
# numbers. We need to decrement the column number by 1 at
383-
# least.
384-
column_offset = 1
385-
row_offset = 0
386-
# See also: https://github.com/pycqa/flake8/issues/169,
387-
# https://github.com/PyCQA/flake8/issues/1372
388-
# On Python 3.9 and earlier, token will be a 4-item tuple with the
389-
# last item being the string. Starting with 3.10, they added to
390-
# the tuple so now instead of it ending with the code that failed
391-
# to parse, it ends with the end of the section of code that
392-
# failed to parse. Luckily the absolute position in the tuple is
393-
# stable across versions so we can use that here
394-
physical_line = token[3]
395-
396-
# NOTE(sigmavirus24): Not all "tokens" have a string as the last
397-
# argument. In this event, let's skip trying to find the correct
398-
# column and row values.
399-
if physical_line is not None:
400-
# NOTE(sigmavirus24): SyntaxErrors also don't exactly have a
401-
# "physical" line so much as what was accumulated by the point
402-
# tokenizing failed.
403-
# See also: https://github.com/pycqa/flake8/issues/169
404-
lines = physical_line.rstrip("\n").split("\n")
405-
row_offset = len(lines) - 1
406-
logical_line = lines[0]
407-
logical_line_length = len(logical_line)
408-
if column > logical_line_length:
409-
column = logical_line_length
410-
row -= row_offset
411-
column -= column_offset
412375
return row, column
413376

414377
def run_ast_checks(self) -> None:

src/flake8/discover_files.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
import logging
55
import os.path
6+
from collections.abc import Callable
67
from collections.abc import Generator
78
from collections.abc import Sequence
8-
from typing import Callable
99

1010
from flake8 import utils
1111

src/flake8/options/manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
import enum
66
import functools
77
import logging
8+
from collections.abc import Callable
89
from collections.abc import Sequence
910
from typing import Any
10-
from typing import Callable
1111

1212
from flake8 import utils
1313
from flake8.plugins.finder import Plugins

tests/integration/test_checker.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from __future__ import annotations
33

44
import importlib.metadata
5-
import sys
65
from unittest import mock
76

87
import pytest
@@ -322,17 +321,10 @@ def test_handling_syntaxerrors_across_pythons():
322321
We need to handle that correctly to avoid crashing.
323322
https://github.com/PyCQA/flake8/issues/1372
324323
"""
325-
if sys.version_info < (3, 10): # pragma: no cover (<3.10)
326-
# Python 3.9 or older
327-
err = SyntaxError(
328-
"invalid syntax", ("<unknown>", 2, 5, "bad python:\n"),
329-
)
330-
expected = (2, 4)
331-
else: # pragma: no cover (3.10+)
332-
err = SyntaxError(
333-
"invalid syntax", ("<unknown>", 2, 1, "bad python:\n", 2, 11),
334-
)
335-
expected = (2, 1)
324+
err = SyntaxError(
325+
"invalid syntax", ("<unknown>", 2, 1, "bad python:\n", 2, 11),
326+
)
327+
expected = (2, 1)
336328
file_checker = checker.FileChecker(
337329
filename="-",
338330
plugins=finder.Checkers([], [], []),

tests/integration/test_main.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,8 @@ def test_tokenization_error_but_not_syntax_error(tmpdir, capsys):
168168
tmpdir.join("t.py").write("b'foo' \\\n")
169169
assert cli.main(["t.py"]) == 1
170170

171-
if hasattr(sys, "pypy_version_info"): # pragma: no cover (pypy)
172-
expected = "t.py:2:1: E999 SyntaxError: end of file (EOF) in multi-line statement\n" # noqa: E501
173-
elif sys.version_info < (3, 10): # pragma: no cover (cp38+)
174-
expected = "t.py:1:8: E999 SyntaxError: unexpected EOF while parsing\n"
171+
if sys.implementation.name == "pypy": # pragma: no cover (pypy)
172+
expected = "t.py:1:9: E999 SyntaxError: unexpected end of file (EOF) in multi-line statement\n" # noqa: E501
175173
else: # pragma: no cover (cp310+)
176174
expected = "t.py:1:10: E999 SyntaxError: unexpected EOF while parsing\n" # noqa: E501
177175

@@ -186,10 +184,8 @@ def test_tokenization_error_is_a_syntax_error(tmpdir, capsys):
186184
tmpdir.join("t.py").write("if True:\n pass\n pass\n")
187185
assert cli.main(["t.py"]) == 1
188186

189-
if hasattr(sys, "pypy_version_info"): # pragma: no cover (pypy)
190-
expected = "t.py:3:2: E999 IndentationError: unindent does not match any outer indentation level\n" # noqa: E501
191-
elif sys.version_info < (3, 10): # pragma: no cover (<cp310)
192-
expected = "t.py:3:5: E999 IndentationError: unindent does not match any outer indentation level\n" # noqa: E501
187+
if sys.implementation.name == "pypy": # pragma: no cover (pypy)
188+
expected = "t.py:3:3: E999 IndentationError: unindent does not match any outer indentation level\n" # noqa: E501
193189
else: # pragma: no cover (cp310+)
194190
expected = "t.py:3:7: E999 IndentationError: unindent does not match any outer indentation level\n" # noqa: E501
195191

0 commit comments

Comments
 (0)