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
+29 -13
View File
@@ -4,7 +4,7 @@ from collections.abc import Callable, Generator, Sequence
from contextlib import contextmanager
from tkinter import Canvas, Frame, Misc, PhotoImage, Scrollbar
from typing import Any, ClassVar, Literal, TypedDict, overload, type_check_only
from typing_extensions import Self, TypeAlias, deprecated
from typing_extensions import Self, TypeAlias, deprecated, disjoint_base
__all__ = [
"ScrolledCanvas",
@@ -163,18 +163,34 @@ class _PenState(TypedDict):
_Speed: TypeAlias = str | float
_PolygonCoords: TypeAlias = Sequence[tuple[float, float]]
class Vec2D(tuple[float, float]):
def __new__(cls, x: float, y: float) -> Self: ...
def __add__(self, other: tuple[float, float]) -> Vec2D: ... # type: ignore[override]
@overload # type: ignore[override]
def __mul__(self, other: Vec2D) -> float: ...
@overload
def __mul__(self, other: float) -> Vec2D: ...
def __rmul__(self, other: float) -> Vec2D: ... # type: ignore[override]
def __sub__(self, other: tuple[float, float]) -> Vec2D: ...
def __neg__(self) -> Vec2D: ...
def __abs__(self) -> float: ...
def rotate(self, angle: float) -> Vec2D: ...
if sys.version_info >= (3, 12):
class Vec2D(tuple[float, float]):
def __new__(cls, x: float, y: float) -> Self: ...
def __add__(self, other: tuple[float, float]) -> Vec2D: ... # type: ignore[override]
@overload # type: ignore[override]
def __mul__(self, other: Vec2D) -> float: ...
@overload
def __mul__(self, other: float) -> Vec2D: ...
def __rmul__(self, other: float) -> Vec2D: ... # type: ignore[override]
def __sub__(self, other: tuple[float, float]) -> Vec2D: ...
def __neg__(self) -> Vec2D: ...
def __abs__(self) -> float: ...
def rotate(self, angle: float) -> Vec2D: ...
else:
@disjoint_base
class Vec2D(tuple[float, float]):
def __new__(cls, x: float, y: float) -> Self: ...
def __add__(self, other: tuple[float, float]) -> Vec2D: ... # type: ignore[override]
@overload # type: ignore[override]
def __mul__(self, other: Vec2D) -> float: ...
@overload
def __mul__(self, other: float) -> Vec2D: ...
def __rmul__(self, other: float) -> Vec2D: ... # type: ignore[override]
def __sub__(self, other: tuple[float, float]) -> Vec2D: ...
def __neg__(self) -> Vec2D: ...
def __abs__(self) -> float: ...
def rotate(self, angle: float) -> Vec2D: ...
# Does not actually inherit from Canvas, but dynamically gets all methods of Canvas
class ScrolledCanvas(Canvas, Frame): # type: ignore[misc]