Add @disjoint_base decorator in the stdlib (#14599)

And fix some other new stubtest finds.
This commit is contained in:
Jelle Zijlstra
2025-08-24 07:27:14 -07:00
committed by GitHub
parent 2565f34946
commit e8ba06f710
55 changed files with 701 additions and 307 deletions
+17 -9
View File
@@ -11,7 +11,7 @@ from _ast import (
from _typeshed import ReadableBuffer, Unused
from collections.abc import Iterable, Iterator, Sequence
from typing import Any, ClassVar, Generic, Literal, TypedDict, TypeVar as _TypeVar, overload, type_check_only
from typing_extensions import Self, Unpack, deprecated
from typing_extensions import Self, Unpack, deprecated, disjoint_base
if sys.version_info >= (3, 13):
from _ast import PyCF_OPTIMIZED_AST as PyCF_OPTIMIZED_AST
@@ -30,16 +30,24 @@ class _Attributes(TypedDict, Generic[_EndPositionT], total=False):
# The various AST classes are implemented in C, and imported from _ast at runtime,
# but they consider themselves to live in the ast module,
# so we'll define the stubs in this file.
class AST:
if sys.version_info >= (3, 10):
if sys.version_info >= (3, 12):
@disjoint_base
class AST:
__match_args__ = ()
_attributes: ClassVar[tuple[str, ...]]
_fields: ClassVar[tuple[str, ...]]
if sys.version_info >= (3, 13):
_field_types: ClassVar[dict[str, Any]]
_attributes: ClassVar[tuple[str, ...]]
_fields: ClassVar[tuple[str, ...]]
if sys.version_info >= (3, 13):
_field_types: ClassVar[dict[str, Any]]
if sys.version_info >= (3, 14):
def __replace__(self) -> Self: ...
if sys.version_info >= (3, 14):
def __replace__(self) -> Self: ...
else:
class AST:
if sys.version_info >= (3, 10):
__match_args__ = ()
_attributes: ClassVar[tuple[str, ...]]
_fields: ClassVar[tuple[str, ...]]
class mod(AST): ...