Skip to content

Commit b266f3e

Browse files
authored
Drop Python 3.8 support in ast (#13766)
1 parent 616ca7d commit b266f3e

File tree

2 files changed

+16
-52
lines changed

2 files changed

+16
-52
lines changed

stdlib/_ast.pyi

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -130,17 +130,6 @@ if sys.version_info >= (3, 10):
130130
pattern as pattern,
131131
)
132132

133-
if sys.version_info < (3, 9):
134-
from ast import (
135-
AugLoad as AugLoad,
136-
AugStore as AugStore,
137-
ExtSlice as ExtSlice,
138-
Index as Index,
139-
Param as Param,
140-
Suite as Suite,
141-
slice as slice,
142-
)
143-
144133
PyCF_ALLOW_TOP_LEVEL_AWAIT: Literal[8192]
145134
PyCF_ONLY_AST: Literal[1024]
146135
PyCF_TYPE_COMMENTS: Literal[4096]

stdlib/ast.pyi

Lines changed: 16 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,8 +1144,7 @@ class Tuple(expr):
11441144
__match_args__ = ("elts", "ctx")
11451145
elts: list[expr]
11461146
ctx: expr_context # Not present in Python < 3.13 if not passed to `__init__`
1147-
if sys.version_info >= (3, 9):
1148-
dims: list[expr]
1147+
dims: list[expr]
11491148
if sys.version_info >= (3, 13):
11501149
def __init__(self, elts: list[expr] = ..., ctx: expr_context = ..., **kwargs: Unpack[_Attributes]) -> None: ...
11511150
else:
@@ -1155,16 +1154,10 @@ class Tuple(expr):
11551154
def __replace__(self, *, elts: list[expr] = ..., ctx: expr_context = ..., **kwargs: Unpack[_Attributes]) -> Self: ...
11561155

11571156
@deprecated("Deprecated since Python 3.9.")
1158-
class slice(AST): ... # deprecated and moved to ast.py for >= (3, 9)
1157+
class slice(AST): ...
11591158

1160-
if sys.version_info >= (3, 9):
1161-
_Slice: typing_extensions.TypeAlias = expr
1162-
_SliceAttributes: typing_extensions.TypeAlias = _Attributes
1163-
else:
1164-
# alias for use with variables named slice
1165-
_Slice: typing_extensions.TypeAlias = slice
1166-
1167-
class _SliceAttributes(TypedDict): ...
1159+
_Slice: typing_extensions.TypeAlias = expr
1160+
_SliceAttributes: typing_extensions.TypeAlias = _Attributes
11681161

11691162
class Slice(_Slice):
11701163
if sys.version_info >= (3, 10):
@@ -1187,37 +1180,26 @@ class Slice(_Slice):
11871180
) -> Self: ...
11881181

11891182
@deprecated("Deprecated since Python 3.9. Use ast.Tuple instead.")
1190-
class ExtSlice(slice): # deprecated and moved to ast.py if sys.version_info >= (3, 9)
1191-
if sys.version_info >= (3, 9):
1192-
def __new__(cls, dims: Iterable[slice] = (), **kwargs: Unpack[_SliceAttributes]) -> Tuple: ... # type: ignore[misc]
1193-
else:
1194-
dims: list[slice]
1195-
def __init__(self, dims: list[slice], **kwargs: Unpack[_SliceAttributes]) -> None: ...
1183+
class ExtSlice(slice):
1184+
def __new__(cls, dims: Iterable[slice] = (), **kwargs: Unpack[_SliceAttributes]) -> Tuple: ... # type: ignore[misc]
11961185

11971186
@deprecated("Deprecated since Python 3.9. Use the index value directly instead.")
1198-
class Index(slice): # deprecated and moved to ast.py if sys.version_info >= (3, 9)
1199-
if sys.version_info >= (3, 9):
1200-
def __new__(cls, value: expr, **kwargs: Unpack[_SliceAttributes]) -> expr: ... # type: ignore[misc]
1201-
else:
1202-
value: expr
1203-
def __init__(self, value: expr, **kwargs: Unpack[_SliceAttributes]) -> None: ...
1187+
class Index(slice):
1188+
def __new__(cls, value: expr, **kwargs: Unpack[_SliceAttributes]) -> expr: ... # type: ignore[misc]
12041189

12051190
class expr_context(AST): ...
12061191

12071192
@deprecated("Deprecated since Python 3.9. Unused in Python 3.")
1208-
class AugLoad(expr_context): ... # deprecated and moved to ast.py if sys.version_info >= (3, 9)
1193+
class AugLoad(expr_context): ...
12091194

12101195
@deprecated("Deprecated since Python 3.9. Unused in Python 3.")
1211-
class AugStore(expr_context): ... # deprecated and moved to ast.py if sys.version_info >= (3, 9)
1196+
class AugStore(expr_context): ...
12121197

12131198
@deprecated("Deprecated since Python 3.9. Unused in Python 3.")
1214-
class Param(expr_context): ... # deprecated and moved to ast.py if sys.version_info >= (3, 9)
1199+
class Param(expr_context): ...
12151200

12161201
@deprecated("Deprecated since Python 3.9. Unused in Python 3.")
1217-
class Suite(mod): # deprecated and moved to ast.py if sys.version_info >= (3, 9)
1218-
if sys.version_info < (3, 9):
1219-
body: list[stmt]
1220-
def __init__(self, body: list[stmt]) -> None: ...
1202+
class Suite(mod): ...
12211203

12221204
class Load(expr_context): ...
12231205
class Store(expr_context): ...
@@ -1702,8 +1684,7 @@ if sys.version_info >= (3, 12):
17021684
) -> Self: ...
17031685

17041686
class _ABC(type):
1705-
if sys.version_info >= (3, 9):
1706-
def __init__(cls, *args: Unused) -> None: ...
1687+
def __init__(cls, *args: Unused) -> None: ...
17071688

17081689
if sys.version_info < (3, 14):
17091690
@deprecated("Replaced by ast.Constant; removed in Python 3.14")
@@ -1894,14 +1875,11 @@ if sys.version_info >= (3, 13):
18941875
show_empty: bool = False,
18951876
) -> str: ...
18961877

1897-
elif sys.version_info >= (3, 9):
1878+
else:
18981879
def dump(
18991880
node: AST, annotate_fields: bool = True, include_attributes: bool = False, *, indent: int | str | None = None
19001881
) -> str: ...
19011882

1902-
else:
1903-
def dump(node: AST, annotate_fields: bool = True, include_attributes: bool = False) -> str: ...
1904-
19051883
def copy_location(new_node: _T, old_node: AST) -> _T: ...
19061884
def fix_missing_locations(node: _T) -> _T: ...
19071885
def increment_lineno(node: _T, n: int = 1) -> _T: ...
@@ -2059,8 +2037,5 @@ class NodeTransformer(NodeVisitor):
20592037
# The usual return type is AST | None, but Iterable[AST]
20602038
# is also allowed in some cases -- this needs to be mapped.
20612039

2062-
if sys.version_info >= (3, 9):
2063-
def unparse(ast_obj: AST) -> str: ...
2064-
2065-
if sys.version_info >= (3, 9):
2066-
def main() -> None: ...
2040+
def unparse(ast_obj: AST) -> str: ...
2041+
def main() -> None: ...

0 commit comments

Comments
 (0)