This commit is contained in:
wittmannzl103469 committed 2026-11-05 15:08:42 +01:00
1 parent de41a02749
commit 9af09cebd3
764 files changed
+54218 -78859

No files matched your search

+192 -289
View File
@@ -1,305 +1,208 @@
import sys
from collections.abc import Callable, Collection, Iterator
from typing import (
ClassVar,
Literal,
SupportsIndex,
Dict,
Iterator,
List,
Sequence,
Tuple,
TypeVar,
Union,
overload,
Callable,
Any,
Optional,
)
from pygame.typing import Point, RectLike, SequenceLike
from typing_extensions import deprecated # added in 3.13
from ._common import Coordinate, Literal, RectValue
if sys.version_info >= (3, 11):
from typing import Self
if sys.version_info >= (3, 9):
from collections.abc import Collection
else:
from typing_extensions import Self
from typing import Collection
from types import EllipsisType
_N = TypeVar("_N", int, float)
_K = TypeVar("_K")
_V = TypeVar("_V")
_T = TypeVar("_T")
_RectTypeCompatible_co = TypeVar(
"_RectTypeCompatible_co", bound=RectLike, covariant=True
)
class _GenericRect(Collection[_N]):
@property
def x(self) -> _N: ...
@x.setter
def x(self, value: float) -> None: ...
@property
def y(self) -> _N: ...
@y.setter
def y(self, value: float) -> None: ...
@property
def top(self) -> _N: ...
@top.setter
def top(self, value: float) -> None: ...
@property
def left(self) -> _N: ...
@left.setter
def left(self, value: float) -> None: ...
@property
def bottom(self) -> _N: ...
@bottom.setter
def bottom(self, value: float) -> None: ...
@property
def right(self) -> _N: ...
@right.setter
def right(self, value: float) -> None: ...
@property
def topleft(self) -> tuple[_N, _N]: ...
@topleft.setter
def topleft(self, value: Point) -> None: ...
@property
def bottomleft(self) -> tuple[_N, _N]: ...
@bottomleft.setter
def bottomleft(self, value: Point) -> None: ...
@property
def topright(self) -> tuple[_N, _N]: ...
@topright.setter
def topright(self, value: Point) -> None: ...
@property
def bottomright(self) -> tuple[_N, _N]: ...
@bottomright.setter
def bottomright(self, value: Point) -> None: ...
@property
def midtop(self) -> tuple[_N, _N]: ...
@midtop.setter
def midtop(self, value: Point) -> None: ...
@property
def midleft(self) -> tuple[_N, _N]: ...
@midleft.setter
def midleft(self, value: Point) -> None: ...
@property
def midbottom(self) -> tuple[_N, _N]: ...
@midbottom.setter
def midbottom(self, value: Point) -> None: ...
@property
def midright(self) -> tuple[_N, _N]: ...
@midright.setter
def midright(self, value: Point) -> None: ...
@property
def center(self) -> tuple[_N, _N]: ...
@center.setter
def center(self, value: Point) -> None: ...
@property
def relcenter(self) -> tuple[_N, _N]: ...
@relcenter.setter
def relcenter(self, value: Point) -> None: ...
@property
def centerx(self) -> _N: ...
@centerx.setter
def centerx(self, value: float) -> None: ...
@property
def centery(self) -> _N: ...
@centery.setter
def centery(self, value: float) -> None: ...
@property
def size(self) -> tuple[_N, _N]: ...
@size.setter
def size(self, value: Point) -> None: ...
@property
def width(self) -> _N: ...
@width.setter
def width(self, value: float) -> None: ...
@property
def height(self) -> _N: ...
@height.setter
def height(self, value: float) -> None: ...
@property
def w(self) -> _N: ...
@w.setter
def w(self, value: float) -> None: ...
@property
def h(self) -> _N: ...
@h.setter
def h(self, value: float) -> None: ...
__hash__: ClassVar[None] # type: ignore[assignment]
@overload
def __init__(
self, left: float, top: float, width: float, height: float, /
) -> None: ...
@overload
def __init__(self, left_top: Point, width_height: Point, /) -> None: ...
@overload
def __init__(self, single_arg: RectLike, /) -> None: ...
@overload
def __init__(self) -> None: ...
def __len__(self) -> Literal[4]: ...
def __iter__(self) -> Iterator[_N]: ...
@overload
def __getitem__(self, i: SupportsIndex) -> _N: ...
@overload
def __getitem__(self, s: slice | EllipsisType) -> list[_N]: ...
@overload
def __setitem__(self, key: int, value: float) -> None: ...
@overload
def __setitem__(
self, key: slice | EllipsisType, value: float | RectLike
) -> None: ...
def __copy__(self) -> Self: ...
def copy(self) -> Self: ...
@overload
def move(self, x: float, y: float, /) -> Self: ...
@overload
def move(self, move_by: Point, /) -> Self: ...
@overload
def move_ip(self, x: float, y: float, /) -> None: ...
@overload
def move_ip(self, move_by: Point, /) -> None: ...
def move_to(self, **kwargs: float | Point) -> Self: ...
@overload
def inflate(self, x: float, y: float, /) -> Self: ...
@overload
def inflate(self, inflate_by: Point, /) -> Self: ...
@overload
def inflate_ip(self, x: float, y: float, /) -> None: ...
@overload
def inflate_ip(self, inflate_by: Point, /) -> None: ...
@overload
def scale_by(self, x: float, y: float = ...) -> Self: ...
@overload
def scale_by(self, scale_by: Point) -> Self: ...
@overload
def scale_by_ip(self, x: float, y: float = ...) -> None: ...
@overload
def scale_by_ip(self, scale_by: Point) -> None: ...
@overload
def update(
self, left: float, top: float, width: float, height: float, /
) -> None: ...
@overload
def update(self, left_top: Point, width_height: Point, /) -> None: ...
@overload
def update(self, single_arg: RectLike, /) -> None: ...
@overload
def clamp(self, rect: RectLike, /) -> Self: ...
@overload
def clamp(self, left_top: Point, width_height: Point, /) -> Self: ...
@overload
def clamp(
self, left: float, top: float, width: float, height: float, /
) -> Self: ...
@overload
def clamp_ip(self, rect: RectLike, /) -> None: ...
@overload
def clamp_ip(self, left_top: Point, width_height: Point, /) -> None: ...
@overload
def clamp_ip(
self, left: float, top: float, width: float, height: float, /
) -> None: ...
@overload
def clip(self, rect: RectLike, /) -> Self: ...
@overload
def clip(self, left_top: Point, width_height: Point, /) -> Self: ...
@overload
def clip(self, left: float, top: float, width: float, height: float, /) -> Self: ...
@overload
def clipline(
self, x1: float, x2: float, x3: float, x4: float, /
) -> tuple[tuple[_N, _N], tuple[_N, _N]] | tuple[()]: ...
@overload
def clipline(
self, first_point: Point, second_point: Point, /
) -> tuple[tuple[_N, _N], tuple[_N, _N]] | tuple[()]: ...
@overload
def clipline(
self, rect_arg: RectLike, /
) -> tuple[tuple[_N, _N], tuple[_N, _N]] | tuple[()]: ...
@overload
def union(self, rect: RectLike, /) -> Self: ...
@overload
def union(self, left_top: Point, width_height: Point, /) -> Self: ...
@overload
def union(
self, left: float, top: float, width: float, height: float, /
) -> Self: ...
@overload
def union_ip(self, rect: RectLike, /) -> None: ...
@overload
def union_ip(self, left_top: Point, width_height: Point, /) -> None: ...
@overload
def union_ip(
self, left: float, top: float, width: float, height: float, /
) -> None: ...
def unionall(self, rect: SequenceLike[_RectTypeCompatible_co], /) -> Self: ...
def unionall_ip(
self, rect_SequenceLike: SequenceLike[_RectTypeCompatible_co], /
) -> None: ...
@overload
def fit(self, rect: RectLike, /) -> Self: ...
@overload
def fit(self, left_top: Point, width_height: Point, /) -> Self: ...
@overload
def fit(self, left: float, top: float, width: float, height: float, /) -> Self: ...
def normalize(self) -> None: ...
def __contains__(self, rect: RectLike | _N, /) -> bool: ... # type: ignore[override]
@overload
def contains(self, rect: RectLike, /) -> bool: ...
@overload
def contains(self, left_top: Point, width_height: Point, /) -> bool: ...
@overload
def contains(
self, left: float, top: float, width: float, height: float, /
) -> bool: ...
@overload
def collidepoint(self, x: float, y: float, /) -> bool: ...
@overload
def collidepoint(self, x_y: Point, /) -> bool: ...
@overload
def colliderect(self, rect: RectLike, /) -> bool: ...
@overload
def colliderect(self, left_top: Point, width_height: Point, /) -> bool: ...
@overload
def colliderect(
self, left: float, top: float, width: float, height: float, /
) -> bool: ...
def collidelist(
self, rect_list: SequenceLike[_RectTypeCompatible_co], /
) -> int: ...
def collidelistall(
self, rect_list: SequenceLike[_RectTypeCompatible_co], /
) -> list[int]: ...
def collideobjectsall(
self, objects: SequenceLike[_T], key: Callable[[_T], RectLike] | None = None
) -> list[_T]: ...
def collideobjects(
self, objects: SequenceLike[_T], key: Callable[[_T], RectLike] | None = None
) -> _T | None: ...
@overload
def collidedict(
self,
rect_dict: dict[_RectTypeCompatible_co, _V],
values: Literal[False] = False,
) -> tuple[_RectTypeCompatible_co, _V] | None: ...
@overload
def collidedict(
self, rect_dict: dict[_K, _RectTypeCompatible_co], values: Literal[True]
) -> tuple[_K, _RectTypeCompatible_co] | None: ...
@overload
def collidedictall(
self,
rect_dict: dict[_RectTypeCompatible_co, _V],
values: Literal[False] = False,
) -> list[tuple[_RectTypeCompatible_co, _V]]: ...
@overload
def collidedictall(
self, rect_dict: dict[_K, _RectTypeCompatible_co], values: Literal[True]
) -> list[tuple[_K, _RectTypeCompatible_co]]: ...
# Rect confirms to the Collection ABC, since it also confirms to
# Sized, Iterable and Container ABCs
class Rect(_GenericRect[int]): ...
class FRect(_GenericRect[float]): ...
class Rect(Collection[int]):
x: int
y: int
top: int
left: int
bottom: int
right: int
topleft: Tuple[int, int]
bottomleft: Tuple[int, int]
topright: Tuple[int, int]
bottomright: Tuple[int, int]
midtop: Tuple[int, int]
midleft: Tuple[int, int]
midbottom: Tuple[int, int]
midright: Tuple[int, int]
center: Tuple[int, int]
centerx: int
centery: int
size: Tuple[int, int]
width: int
height: int
w: int
h: int
__hash__: None # type: ignore
__safe_for_unpickling__: Literal[True]
@overload
def __init__(
self, left: float, top: float, width: float, height: float
) -> None: ...
@overload
def __init__(self, left_top: Coordinate, width_height: Coordinate) -> None: ...
@overload
def __init__(self, single_arg: RectValue) -> None: ...
def __len__(self) -> Literal[4]: ...
def __iter__(self) -> Iterator[int]: ...
@overload
def __getitem__(self, i: int) -> int: ...
@overload
def __getitem__(self, s: slice) -> List[int]: ...
@overload
def __setitem__(self, key: int, value: int) -> None: ...
@overload
def __setitem__(self, key: slice, value: Union[int, Rect]) -> None: ...
def __copy__(self) -> Rect: ...
copy = __copy__
@overload
def move(self, x: float, y: float) -> Rect: ...
@overload
def move(self, move_by: Coordinate) -> Rect: ...
@overload
def move_ip(self, x: float, y: float) -> None: ...
@overload
def move_ip(self, move_by: Coordinate) -> None: ...
@overload
def inflate(self, x: float, y: float) -> Rect: ...
@overload
def inflate(self, inflate_by: Coordinate) -> Rect: ...
@overload
def inflate_ip(self, x: float, y: float) -> None: ...
@overload
def inflate_ip(self, inflate_by: Coordinate) -> None: ...
@overload
def scale_by(self, x: float, y: float) -> Rect: ...
@overload
def scale_by(self, scale_by: Coordinate) -> Rect: ...
@overload
def scale_by_ip(self, x: float, y: float) -> None: ...
@overload
def scale_by_ip(self, scale_by: Coordinate) -> None: ...
@overload
def update(self, left: float, top: float, width: float, height: float) -> None: ...
@overload
def update(self, left_top: Coordinate, width_height: Coordinate) -> None: ...
@overload
def update(self, single_arg: RectValue) -> None: ...
@overload
def clamp(self, rect: RectValue) -> Rect: ...
@overload
def clamp(self, left_top: Coordinate, width_height: Coordinate) -> Rect: ...
@overload
def clamp(self, left: float, top: float, width: float, height: float) -> Rect: ...
@overload
def clamp_ip(self, rect: RectValue) -> None: ...
@overload
def clamp_ip(self, left_top: Coordinate, width_height: Coordinate) -> None: ...
@overload
def clamp_ip(
self, left: float, top: float, width: float, height: float
) -> None: ...
@overload
def clip(self, rect: RectValue) -> Rect: ...
@overload
def clip(self, left_top: Coordinate, width_height: Coordinate) -> Rect: ...
@overload
def clip(self, left: float, top: float, width: float, height: float) -> Rect: ...
@overload
def clipline(
self, x1: float, x2: float, x3: float, x4: float
) -> Union[Tuple[Tuple[int, int], Tuple[int, int]], Tuple[()]]: ...
@overload
def clipline(
self, first_coordinate: Coordinate, second_coordinate: Coordinate
) -> Union[Tuple[Tuple[int, int], Tuple[int, int]], Tuple[()]]: ...
@overload
def clipline(
self, rect_arg: RectValue
) -> Union[Tuple[Tuple[int, int], Tuple[int, int]], Tuple[()]]: ...
@overload
def union(self, rect: RectValue) -> Rect: ...
@overload
def union(self, left_top: Coordinate, width_height: Coordinate) -> Rect: ...
@overload
def union(self, left: float, top: float, width: float, height: float) -> Rect: ...
@overload
def union_ip(self, rect: RectValue) -> None: ...
@overload
def union_ip(self, left_top: Coordinate, width_height: Coordinate) -> None: ...
@overload
def union_ip(
self, left: float, top: float, width: float, height: float
) -> None: ...
def unionall(self, rect: Sequence[RectValue]) -> Rect: ...
def unionall_ip(self, rects: Sequence[RectValue]) -> None: ...
@overload
def fit(self, rect: RectValue) -> Rect: ...
@overload
def fit(self, left_top: Coordinate, width_height: Coordinate) -> Rect: ...
@overload
def fit(self, left: float, top: float, width: float, height: float) -> Rect: ...
def normalize(self) -> None: ...
def __contains__(self, rect: Union[RectValue, int]) -> bool: ... # type: ignore[override]
@overload
def contains(self, rect: RectValue) -> bool: ...
@overload
def contains(self, left_top: Coordinate, width_height: Coordinate) -> bool: ...
@overload
def contains(
self, left: float, top: float, width: float, height: float
) -> bool: ...
@overload
def collidepoint(self, x: float, y: float) -> bool: ...
@overload
def collidepoint(self, x_y: Coordinate) -> bool: ...
@overload
def colliderect(self, rect: RectValue) -> bool: ...
@overload
def colliderect(self, left_top: Coordinate, width_height: Coordinate) -> bool: ...
@overload
def colliderect(
self, left: float, top: float, width: float, height: float
) -> bool: ...
def collidelist(self, rects: Sequence[RectValue]) -> int: ...
def collidelistall(self, rects: Sequence[RectValue]) -> List[int]: ...
def collideobjectsall(
self, objects: Sequence[_T], key: Optional[Callable[[_T], RectValue]] = None
) -> List[_T]: ...
def collideobjects(
self, objects: Sequence[_T], key: Optional[Callable[[_T], RectValue]] = None
) -> Optional[_T]: ...
# Also undocumented: the dict collision methods take a 'values' argument
# that defaults to False. If it is False, the keys in rect_dict must be
# Rect-like; otherwise, the values must be Rects.
@overload
def collidedict(
self, rect_dict: Dict[RectValue, _V], values: bool = ...
) -> Tuple[RectValue, _V]: ...
@overload
def collidedict(
self, rect_dict: Dict[_K, "Rect"], values: bool
) -> Tuple[_K, "Rect"]: ...
@overload
def collidedictall(
self, rect_dict: Dict[RectValue, _V], values: bool = ...
) -> List[Tuple[RectValue, _V]]: ...
@overload
def collidedictall(
self, rect_dict: Dict[_K, "Rect"], values: bool
) -> List[Tuple[_K, "Rect"]]: ...
@deprecated("Use `Rect` instead (RectType is an old alias)")
class RectType(Rect): ...
@deprecated("Use `FRect` instead (FRectType is an old alias)")
class FRectType(FRect): ...
RectType = Rect