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
+11 -4
View File
@@ -4,7 +4,7 @@ from collections.abc import Callable, Generator, Iterable, Sequence
from re import Pattern
from token import *
from typing import Any, Final, NamedTuple, TextIO, type_check_only
from typing_extensions import TypeAlias
from typing_extensions import TypeAlias, disjoint_base
if sys.version_info < (3, 12):
# Avoid double assignment to Final name by imports, which pyright objects to.
@@ -115,9 +115,16 @@ class _TokenInfo(NamedTuple):
end: _Position
line: str
class TokenInfo(_TokenInfo):
@property
def exact_type(self) -> int: ...
if sys.version_info >= (3, 12):
class TokenInfo(_TokenInfo):
@property
def exact_type(self) -> int: ...
else:
@disjoint_base
class TokenInfo(_TokenInfo):
@property
def exact_type(self) -> int: ...
# Backwards compatible tokens can be sequences of a shorter length too
_Token: TypeAlias = TokenInfo | Sequence[int | str | _Position]