mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-05-06 21:43:59 +08:00
Add @disjoint_base decorator in the stdlib (#14599)
And fix some other new stubtest finds.
This commit is contained in:
+29
-13
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user