Skip to content

Commit f636a0f

Browse files
authored
Handle removal of deprecated ast Constant classes (#630)
Fixes Python 3.14 support.
1 parent 18d3dc2 commit f636a0f

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/flake8_comprehensions/__init__.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,8 @@ def run(self) -> Generator[tuple[int, int, str, type[Any]]]:
207207
for keyword in node.args[0].keywords:
208208
if keyword.arg != "reverse":
209209
continue
210-
if isinstance(keyword.value, ast.NameConstant):
210+
if isinstance(keyword.value, ast.Constant):
211211
reverse_flag_value = bool(keyword.value.value)
212-
elif isinstance(keyword.value, ast.Num):
213-
reverse_flag_value = bool(keyword.value.n)
214212
else:
215213
# Complex value
216214
reverse_flag_value = None
@@ -267,8 +265,8 @@ def run(self) -> Generator[tuple[int, int, str, type[Any]]]:
267265
and node.args[0].slice.upper is None
268266
and isinstance(node.args[0].slice.step, ast.UnaryOp)
269267
and isinstance(node.args[0].slice.step.op, ast.USub)
270-
and isinstance(node.args[0].slice.step.operand, ast.Num)
271-
and node.args[0].slice.step.operand.n == 1
268+
and isinstance(node.args[0].slice.step.operand, ast.Constant)
269+
and node.args[0].slice.step.operand.value == 1
272270
):
273271
yield (
274272
node.lineno,

0 commit comments

Comments
 (0)