Skip to content

Commit a62c966

Browse files
authored
Merge pull request #857 from asottile/3-8-1-plus
require 3.8.1+
2 parents 706789e + 5742eef commit a62c966

File tree

3 files changed

+6
-21
lines changed

3 files changed

+6
-21
lines changed

pyupgrade/_plugins/versioned_branches.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,13 @@ def _find_if_else_block(tokens: list[Token], i: int) -> tuple[Block, Block]:
2525
return if_block, else_block
2626

2727

28-
def _find_elif(tokens: list[Token], i: int) -> int:
29-
while tokens[i].src != 'elif': # pragma: no cover (only for <3.8.1)
30-
i -= 1
31-
return i
32-
33-
3428
def _fix_py3_block(i: int, tokens: list[Token]) -> None:
3529
if tokens[i].src == 'if':
3630
if_block = Block.find(tokens, i)
3731
if_block.dedent(tokens)
3832
del tokens[if_block.start:if_block.block]
3933
else:
40-
if_block = Block.find(tokens, _find_elif(tokens, i))
34+
if_block = Block.find(tokens, i)
4135
if_block.replace_condition(tokens, [Token('NAME', 'else')])
4236

4337

@@ -47,8 +41,7 @@ def _fix_py2_block(i: int, tokens: list[Token]) -> None:
4741
else_block.dedent(tokens)
4842
del tokens[if_block.start:else_block.block]
4943
else:
50-
j = _find_elif(tokens, i)
51-
if_block, else_block = _find_if_else_block(tokens, j)
44+
if_block, else_block = _find_if_else_block(tokens, i)
5245
del tokens[if_block.start:else_block.start]
5346

5447

@@ -59,8 +52,7 @@ def _fix_py3_block_else(i: int, tokens: list[Token]) -> None:
5952
del tokens[if_block.end:else_block.end]
6053
del tokens[if_block.start:if_block.block]
6154
else:
62-
j = _find_elif(tokens, i)
63-
if_block, else_block = _find_if_else_block(tokens, j)
55+
if_block, else_block = _find_if_else_block(tokens, i)
6456
del tokens[if_block.end:else_block.end]
6557
if_block.replace_condition(tokens, [Token('NAME', 'else')])
6658

pyupgrade/_token_helpers.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,10 @@ def find_open_paren(tokens: list[Token], i: int) -> int:
4949

5050

5151
def find_end(tokens: list[Token], i: int) -> int:
52-
while tokens[i].name not in {'NEWLINE', 'ENDMARKER'}:
53-
i += 1
54-
55-
# depending on the version of python, some will not emit
56-
# NEWLINE('') at the end of a file which does not end with a
57-
# newline (for example 3.7.0)
58-
if tokens[i].name == 'ENDMARKER': # pragma: no cover
59-
i -= 1
60-
else:
52+
while tokens[i].name != 'NEWLINE':
6153
i += 1
6254

55+
i += 1
6356
return i
6457

6558

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ classifiers =
2020
packages = find:
2121
install_requires =
2222
tokenize-rt>=3.2.0
23-
python_requires = >=3.8
23+
python_requires = >=3.8.1
2424

2525
[options.packages.find]
2626
exclude =

0 commit comments

Comments
 (0)