Drop Python 3.8 support in ast (#13766)

This commit is contained in:
Joren Hammudoglu
2025-04-02 08:47:13 +02:00
committed by GitHub
parent 616ca7db2c
commit b266f3e746
2 changed files with 16 additions and 52 deletions
-11
View File
@@ -130,17 +130,6 @@ if sys.version_info >= (3, 10):
pattern as pattern,
)
if sys.version_info < (3, 9):
from ast import (
AugLoad as AugLoad,
AugStore as AugStore,
ExtSlice as ExtSlice,
Index as Index,
Param as Param,
Suite as Suite,
slice as slice,
)
PyCF_ALLOW_TOP_LEVEL_AWAIT: Literal[8192]
PyCF_ONLY_AST: Literal[1024]
PyCF_TYPE_COMMENTS: Literal[4096]
+16 -41
View File
@@ -1144,8 +1144,7 @@ class Tuple(expr):
__match_args__ = ("elts", "ctx")
elts: list[expr]
ctx: expr_context # Not present in Python < 3.13 if not passed to `__init__`
if sys.version_info >= (3, 9):
dims: list[expr]
dims: list[expr]
if sys.version_info >= (3, 13):
def __init__(self, elts: list[expr] = ..., ctx: expr_context = ..., **kwargs: Unpack[_Attributes]) -> None: ...
else:
@@ -1155,16 +1154,10 @@ class Tuple(expr):
def __replace__(self, *, elts: list[expr] = ..., ctx: expr_context = ..., **kwargs: Unpack[_Attributes]) -> Self: ...
@deprecated("Deprecated since Python 3.9.")
class slice(AST): ... # deprecated and moved to ast.py for >= (3, 9)
class slice(AST): ...
if sys.version_info >= (3, 9):
_Slice: typing_extensions.TypeAlias = expr
_SliceAttributes: typing_extensions.TypeAlias = _Attributes
else:
# alias for use with variables named slice
_Slice: typing_extensions.TypeAlias = slice
class _SliceAttributes(TypedDict): ...
_Slice: typing_extensions.TypeAlias = expr
_SliceAttributes: typing_extensions.TypeAlias = _Attributes
class Slice(_Slice):
if sys.version_info >= (3, 10):
@@ -1187,37 +1180,26 @@ class Slice(_Slice):
) -> Self: ...
@deprecated("Deprecated since Python 3.9. Use ast.Tuple instead.")
class ExtSlice(slice): # deprecated and moved to ast.py if sys.version_info >= (3, 9)
if sys.version_info >= (3, 9):
def __new__(cls, dims: Iterable[slice] = (), **kwargs: Unpack[_SliceAttributes]) -> Tuple: ... # type: ignore[misc]
else:
dims: list[slice]
def __init__(self, dims: list[slice], **kwargs: Unpack[_SliceAttributes]) -> None: ...
class ExtSlice(slice):
def __new__(cls, dims: Iterable[slice] = (), **kwargs: Unpack[_SliceAttributes]) -> Tuple: ... # type: ignore[misc]
@deprecated("Deprecated since Python 3.9. Use the index value directly instead.")
class Index(slice): # deprecated and moved to ast.py if sys.version_info >= (3, 9)
if sys.version_info >= (3, 9):
def __new__(cls, value: expr, **kwargs: Unpack[_SliceAttributes]) -> expr: ... # type: ignore[misc]
else:
value: expr
def __init__(self, value: expr, **kwargs: Unpack[_SliceAttributes]) -> None: ...
class Index(slice):
def __new__(cls, value: expr, **kwargs: Unpack[_SliceAttributes]) -> expr: ... # type: ignore[misc]
class expr_context(AST): ...
@deprecated("Deprecated since Python 3.9. Unused in Python 3.")
class AugLoad(expr_context): ... # deprecated and moved to ast.py if sys.version_info >= (3, 9)
class AugLoad(expr_context): ...
@deprecated("Deprecated since Python 3.9. Unused in Python 3.")
class AugStore(expr_context): ... # deprecated and moved to ast.py if sys.version_info >= (3, 9)
class AugStore(expr_context): ...
@deprecated("Deprecated since Python 3.9. Unused in Python 3.")
class Param(expr_context): ... # deprecated and moved to ast.py if sys.version_info >= (3, 9)
class Param(expr_context): ...
@deprecated("Deprecated since Python 3.9. Unused in Python 3.")
class Suite(mod): # deprecated and moved to ast.py if sys.version_info >= (3, 9)
if sys.version_info < (3, 9):
body: list[stmt]
def __init__(self, body: list[stmt]) -> None: ...
class Suite(mod): ...
class Load(expr_context): ...
class Store(expr_context): ...
@@ -1702,8 +1684,7 @@ if sys.version_info >= (3, 12):
) -> Self: ...
class _ABC(type):
if sys.version_info >= (3, 9):
def __init__(cls, *args: Unused) -> None: ...
def __init__(cls, *args: Unused) -> None: ...
if sys.version_info < (3, 14):
@deprecated("Replaced by ast.Constant; removed in Python 3.14")
@@ -1894,14 +1875,11 @@ if sys.version_info >= (3, 13):
show_empty: bool = False,
) -> str: ...
elif sys.version_info >= (3, 9):
else:
def dump(
node: AST, annotate_fields: bool = True, include_attributes: bool = False, *, indent: int | str | None = None
) -> str: ...
else:
def dump(node: AST, annotate_fields: bool = True, include_attributes: bool = False) -> str: ...
def copy_location(new_node: _T, old_node: AST) -> _T: ...
def fix_missing_locations(node: _T) -> _T: ...
def increment_lineno(node: _T, n: int = 1) -> _T: ...
@@ -2059,8 +2037,5 @@ class NodeTransformer(NodeVisitor):
# The usual return type is AST | None, but Iterable[AST]
# is also allowed in some cases -- this needs to be mapped.
if sys.version_info >= (3, 9):
def unparse(ast_obj: AST) -> str: ...
if sys.version_info >= (3, 9):
def main() -> None: ...
def unparse(ast_obj: AST) -> str: ...
def main() -> None: ...