Skip to content

Commit 049b8e3

Browse files
authored
Merge pull request #947 from asottile/drop-3-8
remove support for python 3.8
2 parents 32151ac + c25513c commit 049b8e3

File tree

6 files changed

+16
-44
lines changed

6 files changed

+16
-44
lines changed

.github/workflows/main.yml

+2-2
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

pyupgrade/_plugins/typing_classes.py

+5-12
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import ast
44
import functools
5-
import sys
65
from typing import Iterable
76

87
from tokenize_rt import Offset
@@ -24,19 +23,13 @@ def _unparse(node: ast.expr) -> str:
2423
elif isinstance(node, ast.Attribute):
2524
return ''.join((_unparse(node.value), '.', node.attr))
2625
elif isinstance(node, ast.Subscript):
27-
if sys.version_info >= (3, 9): # pragma: >=3.9 cover
28-
node_slice: ast.expr = node.slice
29-
elif isinstance(node.slice, ast.Index): # pragma: <3.9 cover
30-
node_slice = node.slice.value
31-
else:
32-
raise AssertionError(f'expected Slice: {ast.dump(node)}')
33-
if isinstance(node_slice, ast.Tuple):
34-
if len(node_slice.elts) == 1:
35-
slice_s = f'{_unparse(node_slice.elts[0])},'
26+
if isinstance(node.slice, ast.Tuple):
27+
if len(node.slice.elts) == 1:
28+
slice_s = f'{_unparse(node.slice.elts[0])},'
3629
else:
37-
slice_s = ', '.join(_unparse(elt) for elt in node_slice.elts)
30+
slice_s = ', '.join(_unparse(elt) for elt in node.slice.elts)
3831
else:
39-
slice_s = _unparse(node_slice)
32+
slice_s = _unparse(node.slice)
4033
return f'{_unparse(node.value)}[{slice_s}]'
4134
elif (
4235
isinstance(node, ast.Constant) and

pyupgrade/_plugins/typing_pep563.py

+2-9
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,8 @@ def _process_call(node: ast.Call) -> Iterable[ast.AST]:
9090
def _process_subscript(node: ast.Subscript) -> Iterable[ast.AST]:
9191
name = _get_name(node.value)
9292
if name == 'Annotated':
93-
if sys.version_info >= (3, 9): # pragma: >=3.9 cover
94-
node_slice = node.slice
95-
elif isinstance(node.slice, ast.Index): # pragma: <3.9 cover
96-
node_slice: ast.AST = node.slice.value
97-
else: # pragma: <3.9 cover
98-
node_slice = node.slice
99-
100-
if isinstance(node_slice, ast.Tuple) and node_slice.elts:
101-
yield node_slice.elts[0]
93+
if isinstance(node.slice, ast.Tuple) and node.slice.elts:
94+
yield node.slice.elts[0]
10295
elif name != 'Literal':
10396
yield node.slice
10497

pyupgrade/_plugins/typing_pep604.py

+5-19
Original file line numberDiff line numberDiff line change
@@ -153,14 +153,7 @@ def visit_Subscript(
153153

154154
# don't rewrite forward annotations (unless we know they will be dequoted)
155155
if 'annotations' not in state.from_imports['__future__']:
156-
if (
157-
(sys.version_info >= (3, 9) and _any_arg_is_str(node.slice)) or
158-
(
159-
sys.version_info < (3, 9) and
160-
isinstance(node.slice, ast.Index) and
161-
_any_arg_is_str(node.slice.value)
162-
)
163-
):
156+
if _any_arg_is_str(node.slice):
164157
return
165158

166159
if is_name_attr(
@@ -171,19 +164,12 @@ def visit_Subscript(
171164
):
172165
yield ast_to_offset(node), _fix_optional
173166
elif is_name_attr(node.value, state.from_imports, ('typing',), ('Union',)):
174-
if sys.version_info >= (3, 9): # pragma: >=3.9 cover
175-
node_slice = node.slice
176-
elif isinstance(node.slice, ast.Index): # pragma: <3.9 cover
177-
node_slice: ast.AST = node.slice.value
178-
else: # pragma: <3.9 cover
179-
node_slice = node.slice # unexpected slice type
180-
181-
if isinstance(node_slice, ast.Slice): # not a valid annotation
167+
if isinstance(node.slice, ast.Slice): # not a valid annotation
182168
return
183169

184-
if isinstance(node_slice, ast.Tuple):
185-
if node_slice.elts:
186-
arg_count = len(node_slice.elts)
170+
if isinstance(node.slice, ast.Tuple):
171+
if node.slice.elts:
172+
arg_count = len(node.slice.elts)
187173
else:
188174
return # empty Union
189175
else:

pyupgrade/_plugins/typing_pep646_unpack.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def visit_Subscript(
3535
return
3636

3737
if is_name_attr(node.value, state.from_imports, ('typing',), ('Unpack',)):
38-
if isinstance(parent, (ast.Subscript, ast.Index)):
38+
if isinstance(parent, ast.Subscript):
3939
yield ast_to_offset(node.value), _replace_unpack_with_star
4040

4141

setup.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ classifiers =
2020
packages = find:
2121
install_requires =
2222
tokenize-rt>=5.2.0
23-
python_requires = >=3.8.1
23+
python_requires = >=3.9
2424

2525
[options.packages.find]
2626
exclude =

0 commit comments

Comments
 (0)