Skip to content

Commit e852829

Browse files
authored
Cleanup old ast classes in fastparse (#19743)
The ast `ExtSlice` and `Index` classes have been deprecated (and unused) since Python 3.9. https://docs.python.org/3.9/library/ast.html#ast.AST
1 parent de1247d commit e852829

File tree

1 file changed

+1
-15
lines changed

1 file changed

+1
-15
lines changed

mypy/fastparse.py

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,7 @@
129129
PY_MINOR_VERSION: Final = sys.version_info[1]
130130

131131
import ast as ast3
132-
133-
# TODO: Index, ExtSlice are deprecated in 3.9.
134-
from ast import AST, Attribute, Call, FunctionType, Index, Name, Starred, UAdd, UnaryOp, USub
132+
from ast import AST, Attribute, Call, FunctionType, Name, Starred, UAdd, UnaryOp, USub
135133

136134

137135
def ast3_parse(
@@ -1779,18 +1777,6 @@ def visit_Slice(self, n: ast3.Slice) -> SliceExpr:
17791777
e = SliceExpr(self.visit(n.lower), self.visit(n.upper), self.visit(n.step))
17801778
return self.set_line(e, n)
17811779

1782-
# ExtSlice(slice* dims)
1783-
def visit_ExtSlice(self, n: ast3.ExtSlice) -> TupleExpr:
1784-
# cast for mypyc's benefit on Python 3.9
1785-
return TupleExpr(self.translate_expr_list(cast(Any, n).dims))
1786-
1787-
# Index(expr value)
1788-
def visit_Index(self, n: Index) -> Node:
1789-
# cast for mypyc's benefit on Python 3.9
1790-
value = self.visit(cast(Any, n).value)
1791-
assert isinstance(value, Node)
1792-
return value
1793-
17941780
# Match(expr subject, match_case* cases) # python 3.10 and later
17951781
def visit_Match(self, n: Match) -> MatchStmt:
17961782
node = MatchStmt(

0 commit comments

Comments
 (0)