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
+39 -33
View File
@@ -3,7 +3,7 @@ import types
from collections.abc import Callable, Iterator
from opcode import * # `dis` re-exports it as a part of public API
from typing import IO, Any, Final, NamedTuple
from typing_extensions import Self, TypeAlias
from typing_extensions import Self, TypeAlias, disjoint_base
__all__ = [
"code_info",
@@ -88,39 +88,45 @@ else:
starts_line: int | None
is_jump_target: bool
class Instruction(_Instruction):
if sys.version_info < (3, 13):
if sys.version_info >= (3, 12):
class Instruction(_Instruction):
if sys.version_info < (3, 13):
def _disassemble(self, lineno_width: int = 3, mark_as_current: bool = False, offset_width: int = 4) -> str: ...
if sys.version_info >= (3, 13):
@property
def oparg(self) -> int: ...
@property
def baseopcode(self) -> int: ...
@property
def baseopname(self) -> str: ...
@property
def cache_offset(self) -> int: ...
@property
def end_offset(self) -> int: ...
@property
def jump_target(self) -> int: ...
@property
def is_jump_target(self) -> bool: ...
if sys.version_info >= (3, 14):
@staticmethod
def make(
opname: str,
arg: int | None,
argval: Any,
argrepr: str,
offset: int,
start_offset: int,
starts_line: bool,
line_number: int | None,
label: int | None = None,
positions: Positions | None = None,
cache_info: list[tuple[str, int, Any]] | None = None,
) -> Instruction: ...
else:
@disjoint_base
class Instruction(_Instruction):
def _disassemble(self, lineno_width: int = 3, mark_as_current: bool = False, offset_width: int = 4) -> str: ...
if sys.version_info >= (3, 13):
@property
def oparg(self) -> int: ...
@property
def baseopcode(self) -> int: ...
@property
def baseopname(self) -> str: ...
@property
def cache_offset(self) -> int: ...
@property
def end_offset(self) -> int: ...
@property
def jump_target(self) -> int: ...
@property
def is_jump_target(self) -> bool: ...
if sys.version_info >= (3, 14):
@staticmethod
def make(
opname: str,
arg: int | None,
argval: Any,
argrepr: str,
offset: int,
start_offset: int,
starts_line: bool,
line_number: int | None,
label: int | None = None,
positions: Positions | None = None,
cache_info: list[tuple[str, int, Any]] | None = None,
) -> Instruction: ...
class Bytecode:
codeobj: types.CodeType