Skip to content

Commit f8af4ed

Browse files
authored
Merge pull request #281 from asottile/drop-py38
drop support for python 3.8
2 parents d0cd933 + 1de7243 commit f8af4ed

File tree

14 files changed

+35
-47
lines changed

14 files changed

+35
-47
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ jobs:
1010
main-windows:
1111
uses: asottile/workflows/.github/workflows/[email protected]
1212
with:
13-
env: '["py38"]'
13+
env: '["py39"]'
1414
os: windows-latest
1515
main-linux:
1616
uses: asottile/workflows/.github/workflows/[email protected]
1717
with:
18-
env: '["py38", "py39", "py310", "py311", "py312"]'
18+
env: '["py39", "py310", "py311", "py312"]'
1919
os: ubuntu-latest

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ repos:
1717
rev: v3.13.0
1818
hooks:
1919
- id: reorder-python-imports
20-
args: [--py38-plus, --add-import, 'from __future__ import annotations']
20+
args: [--py39-plus, --add-import, 'from __future__ import annotations']
2121
- repo: https://github.com/asottile/add-trailing-comma
2222
rev: v3.1.0
2323
hooks:
@@ -26,7 +26,7 @@ repos:
2626
rev: v3.16.0
2727
hooks:
2828
- id: pyupgrade
29-
args: [--py38-plus]
29+
args: [--py39-plus]
3030
- repo: https://github.com/hhatto/autopep8
3131
rev: v2.3.1
3232
hooks:

add_trailing_comma/_ast_helpers.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,4 @@ def ast_parse(contents_text: str) -> ast.Module:
1313

1414

1515
def ast_to_offset(node: ast.AST) -> Offset:
16-
candidates = [node]
17-
while candidates:
18-
candidate = candidates.pop()
19-
if hasattr(candidate, 'lineno'):
20-
return Offset(candidate.lineno, candidate.col_offset)
21-
elif hasattr(candidate, '_fields'): # pragma: <3.9 cover
22-
for field in reversed(candidate._fields):
23-
candidates.append(getattr(candidate, field))
24-
else:
25-
raise AssertionError(node)
16+
return Offset(node.lineno, node.col_offset)

add_trailing_comma/_data.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@
33
import ast
44
import collections
55
import pkgutil
6+
from collections.abc import Iterable
67
from typing import Callable
7-
from typing import Iterable
8-
from typing import List
98
from typing import NamedTuple
109
from typing import Protocol
11-
from typing import Tuple
1210
from typing import TypeVar
1311

1412
from tokenize_rt import Offset
@@ -22,8 +20,8 @@ class State(NamedTuple):
2220

2321

2422
AST_T = TypeVar('AST_T', bound=ast.AST)
25-
TokenFunc = Callable[[int, List[Token]], None]
26-
ASTFunc = Callable[[State, AST_T], Iterable[Tuple[Offset, TokenFunc]]]
23+
TokenFunc = Callable[[int, list[Token]], None]
24+
ASTFunc = Callable[[State, AST_T], Iterable[tuple[Offset, TokenFunc]]]
2725

2826
FUNCS = collections.defaultdict(list)
2927

add_trailing_comma/_main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import argparse
44
import sys
5-
from typing import Iterable
6-
from typing import Sequence
5+
from collections.abc import Iterable
6+
from collections.abc import Sequence
77

88
from tokenize_rt import src_to_tokens
99
from tokenize_rt import Token

add_trailing_comma/_plugins/_with.py

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
from __future__ import annotations
22

33
import ast
4-
import sys
5-
from typing import Iterable
4+
from collections.abc import Iterable
65

76
from tokenize_rt import Offset
87
from tokenize_rt import Token
@@ -15,20 +14,20 @@
1514
from add_trailing_comma._token_helpers import fix_brace
1615

1716

18-
if sys.version_info >= (3, 9): # pragma: >=3.9 cover
19-
def _fix_with(i: int, tokens: list[Token]) -> None:
17+
def _fix_with(i: int, tokens: list[Token]) -> None:
18+
i += 1
19+
if tokens[i].name == 'UNIMPORTANT_WS':
2020
i += 1
21-
if tokens[i].name == 'UNIMPORTANT_WS':
22-
i += 1
23-
if tokens[i].src == '(':
24-
fix = find_simple(i, tokens)
25-
# only fix if outer parens are for the with items (next is ':')
26-
if fix is not None and tokens[fix.braces[-1] + 1].src == ':':
27-
fix_brace(tokens, fix, add_comma=True, remove_comma=True)
21+
if tokens[i].src == '(':
22+
fix = find_simple(i, tokens)
23+
# only fix if outer parens are for the with items (next is ':')
24+
if fix is not None and tokens[fix.braces[-1] + 1].src == ':':
25+
fix_brace(tokens, fix, add_comma=True, remove_comma=True)
2826

29-
@register(ast.With)
30-
def visit_With(
31-
state: State,
32-
node: ast.With,
33-
) -> Iterable[tuple[Offset, TokenFunc]]:
34-
yield ast_to_offset(node), _fix_with
27+
28+
@register(ast.With)
29+
def visit_With(
30+
state: State,
31+
node: ast.With,
32+
) -> Iterable[tuple[Offset, TokenFunc]]:
33+
yield ast_to_offset(node), _fix_with

add_trailing_comma/_plugins/calls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import ast
44
import functools
5-
from typing import Iterable
5+
from collections.abc import Iterable
66

77
from tokenize_rt import Offset
88
from tokenize_rt import Token

add_trailing_comma/_plugins/classes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import ast
44
import functools
5-
from typing import Iterable
5+
from collections.abc import Iterable
66

77
from tokenize_rt import Offset
88
from tokenize_rt import Token

add_trailing_comma/_plugins/functions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import ast
44
import functools
5-
from typing import Iterable
5+
from collections.abc import Iterable
66

77
from tokenize_rt import Offset
88
from tokenize_rt import Token

add_trailing_comma/_plugins/imports.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import annotations
22

33
import ast
4-
from typing import Iterable
4+
from collections.abc import Iterable
55

66
from tokenize_rt import Offset
77
from tokenize_rt import Token

0 commit comments

Comments
 (0)