Skip to content

Commit b808ac9

Browse files
committed
Moving Event() to python - bugfix 5.
1 parent 931cf5e commit b808ac9

32 files changed

+129
-70
lines changed

README.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ If you have any questions, please feel free to ask in the `Pygame Community Disc
165165

166166
License
167167
-------
168+
**License Identifier:** LGPL-2.1-or-later
168169

169170
This library is distributed under `GNU LGPL version 2.1`_, which can
170171
be found in the file ``docs/LGPL.txt``. We reserve the right to place

buildconfig/stubs/pygame/_common.pyi

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
from os import PathLike
2-
from typing import IO, Callable, Tuple, Union, TypeVar, Dict, Any, Optional
3-
4-
from typing_extensions import Literal as Literal, SupportsIndex as SupportsIndex
5-
from typing_extensions import Protocol
2+
from typing import IO, Callable, Tuple, Union, TypeVar, Dict, Any, Optional, Protocol, SupportsIndex
63

74
# For functions that take a file name
85
AnyPath = Union[str, bytes, PathLike[str], PathLike[bytes]]

buildconfig/stubs/pygame/color.pyi

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import sys
2-
from typing import Any, Dict, Iterator, Tuple, Union, overload
2+
from typing import Any, Dict, Iterator, SupportsIndex, Tuple, Union, overload
3+
from typing_extensions import deprecated # added in 3.13
34

4-
from ._common import ColorValue, SupportsIndex
5+
from ._common import ColorValue
56

67
if sys.version_info >= (3, 9):
78
from collections.abc import Collection
@@ -79,6 +80,7 @@ class Color(Collection[int]):
7980
def from_normalized(cls, r: float, g: float, b: float, a: float, /) -> Color: ...
8081
def normalize(self) -> Tuple[float, float, float, float]: ...
8182
def correct_gamma(self, gamma: float, /) -> Color: ...
83+
@deprecated("since 2.1.3. Use unpacking instead")
8284
def set_length(self, length: int, /) -> None: ...
8385
def lerp(self, color: ColorValue, amount: float) -> Color: ...
8486
def premul_alpha(self) -> Color: ...

buildconfig/stubs/pygame/cursors.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
from typing import Any, Iterator, Tuple, Union, overload
1+
from typing import Any, Iterator, Literal, Tuple, Union, overload
22

33
from pygame.surface import Surface
44

5-
from ._common import FileArg, Literal, IntCoordinate, Sequence
5+
from ._common import FileArg, IntCoordinate, Sequence
66

77
_Small_string = Tuple[
88
str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str

buildconfig/stubs/pygame/display.pyi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from typing import Dict, List, Optional, Tuple, Union, overload, Literal
2+
from typing_extensions import deprecated # added in 3.13
23

34
from pygame.constants import FULLSCREEN
45
from pygame.surface import Surface
@@ -72,7 +73,9 @@ def gl_set_attribute(flag: int, value: int, /) -> None: ...
7273
def get_active() -> bool: ...
7374
def iconify() -> bool: ...
7475
def toggle_fullscreen() -> int: ...
76+
@deprecated("since 2.1.4. Removed in SDL3")
7577
def set_gamma(red: float, green: float = ..., blue: float = ..., /) -> int: ...
78+
@deprecated("since 2.1.4. Removed in SDL3")
7679
def set_gamma_ramp(
7780
red: Sequence[int], green: Sequence[int], blue: Sequence[int], /
7881
) -> int: ...

buildconfig/stubs/pygame/font.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
from typing import Callable, Hashable, Iterable, List, Optional, Tuple, Union
1+
from typing import Callable, Hashable, Iterable, List, Literal, Optional, Tuple, Union
22

33
from pygame.surface import Surface
44

5-
from ._common import ColorValue, FileArg, Literal
5+
from ._common import ColorValue, FileArg
66

77
# TODO: Figure out a way to type this attribute such that mypy knows it's not
88
# always defined at runtime

buildconfig/stubs/pygame/freetype.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from typing import Any, Callable, Iterable, List, Optional, Tuple, Union
2+
from typing_extensions import deprecated # added in 3.13
23

34
from pygame.color import Color
45
from pygame.rect import Rect
@@ -11,6 +12,7 @@ def get_version(linked: bool = True) -> Tuple[int, int, int]: ...
1112
def init(cache_size: int = 64, resolution: int = 72) -> None: ...
1213
def quit() -> None: ...
1314
def get_init() -> bool: ...
15+
@deprecated("Use `pygame.freetype.get_init` instead")
1416
def was_init() -> bool: ...
1517
def get_cache_size() -> int: ...
1618
def get_default_resolution() -> int: ...

buildconfig/stubs/pygame/image.pyi

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,48 @@
1-
from typing import Optional, Tuple, Union
1+
from typing import Literal, Optional, Tuple, Union
2+
from typing_extensions import deprecated # added in 3.13
23

34
from pygame.bufferproxy import BufferProxy
45
from pygame.surface import Surface
56

6-
from ._common import FileArg, Literal, IntCoordinate, Coordinate
7+
from ._common import FileArg, IntCoordinate, Coordinate
78

89
_BufferStyle = Union[BufferProxy, bytes, bytearray, memoryview]
9-
_to_string_format = Literal[
10+
_to_bytes_format = Literal[
1011
"P", "RGB", "RGBX", "RGBA", "ARGB", "BGRA", "ABGR", "RGBA_PREMULT", "ARGB_PREMULT"
1112
]
1213
_from_buffer_format = Literal["P", "RGB", "BGR", "BGRA", "RGBX", "RGBA", "ARGB"]
13-
_from_string_format = Literal["P", "RGB", "RGBX", "RGBA", "ARGB", "BGRA", "ABGR"]
14+
_from_bytes_format = Literal["P", "RGB", "RGBX", "RGBA", "ARGB", "BGRA", "ABGR"]
1415

1516
def load(file: FileArg, namehint: str = "") -> Surface: ...
1617
def load_sized_svg(file: FileArg, size: Coordinate) -> Surface: ...
1718
def save(surface: Surface, file: FileArg, namehint: str = "") -> None: ...
1819
def get_sdl_image_version(linked: bool = True) -> Optional[Tuple[int, int, int]]: ...
1920
def get_extended() -> bool: ...
21+
@deprecated("since 2.3.0. Use `pygame.image.tobytes` instead")
2022
def tostring(
2123
surface: Surface,
22-
format: _to_string_format,
24+
format: _to_bytes_format,
2325
flipped: bool = False,
2426
pitch: int = -1,
2527
) -> bytes: ...
28+
@deprecated("since 2.3.0. Use `pygame.image.frombytes` instead")
2629
def fromstring(
2730
bytes: bytes,
2831
size: IntCoordinate,
29-
format: _from_string_format,
32+
format: _from_bytes_format,
3033
flipped: bool = False,
3134
pitch: int = -1,
3235
) -> Surface: ...
33-
34-
# the use of tobytes/frombytes is preferred over tostring/fromstring
3536
def tobytes(
3637
surface: Surface,
37-
format: _to_string_format,
38+
format: _to_bytes_format,
3839
flipped: bool = False,
3940
pitch: int = -1,
4041
) -> bytes: ...
4142
def frombytes(
4243
bytes: bytes,
4344
size: IntCoordinate,
44-
format: _from_string_format,
45+
format: _from_bytes_format,
4546
flipped: bool = False,
4647
pitch: int = -1,
4748
) -> Surface: ...

buildconfig/stubs/pygame/joystick.pyi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from typing import Tuple, final
2+
from typing_extensions import deprecated # added in 3.13
23

34
def init() -> None: ...
45
def quit() -> None: ...
@@ -7,9 +8,11 @@ def get_count() -> int: ...
78
@final
89
class JoystickType:
910
def __init__(self, id: int) -> None: ...
11+
@deprecated("since 2.0.0. Multiple initializations are not supported anymore")
1012
def init(self) -> None: ...
1113
def quit(self) -> None: ...
1214
def get_init(self) -> bool: ...
15+
@deprecated("since 2.0.0. Use `pygame.Joystick.get_instance_id` instead")
1316
def get_id(self) -> int: ...
1417
def get_instance_id(self) -> int: ...
1518
def get_guid(self) -> str: ...

buildconfig/stubs/pygame/math.pyi

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ from typing import (
55
Iterator,
66
List,
77
Literal,
8+
SupportsIndex,
89
Tuple,
910
Type,
1011
TypeVar,
@@ -13,13 +14,14 @@ from typing import (
1314
overload,
1415
Optional
1516
)
17+
from typing_extensions import deprecated # added in 3.13
1618

1719
if sys.version_info >= (3, 9):
1820
from collections.abc import Collection
1921
else:
2022
from typing import Collection
2123

22-
from ._common import SupportsIndex, Sequence
24+
from ._common import Sequence
2325

2426
def clamp(value: float, min: float, max: float, /) -> float: ...
2527

@@ -231,6 +233,7 @@ class Vector2(_GenericVector):
231233
def rotate_rad(self: _TVec, angle: float, /) -> _TVec: ...
232234
def rotate_ip(self, angle: float, /) -> None: ...
233235
def rotate_rad_ip(self, angle: float, /) -> None: ...
236+
@deprecated("since 2.1.1. Use `pygame.Vector2.rotate_rad_ip` instead")
234237
def rotate_ip_rad(self, angle: float, /) -> None: ...
235238
def cross(self: _TVec, other: Union[Sequence[float], _TVec], /) -> float: ...
236239
def as_polar(self) -> Tuple[float, float]: ...
@@ -304,23 +307,27 @@ class Vector3(_GenericVector):
304307
def rotate_rad_ip(
305308
self: _TVec, angle: float, axis: Union[Sequence[float], _TVec], /
306309
) -> None: ...
310+
@deprecated("since 2.1.1. Use `pygame.Vector3.rotate_rad_ip` instead")
307311
def rotate_ip_rad(
308312
self: _TVec, angle: float, axis: Union[Sequence[float], _TVec], /
309313
) -> None: ...
310314
def rotate_x(self: _TVec, angle: float, /) -> _TVec: ...
311315
def rotate_x_rad(self: _TVec, angle: float, /) -> _TVec: ...
312316
def rotate_x_ip(self, angle: float, /) -> None: ...
313317
def rotate_x_rad_ip(self, angle: float, /) -> None: ...
318+
@deprecated("since 2.1.1. Use `pygame.Vector3.rotate_x_rad_ip` instead")
314319
def rotate_x_ip_rad(self, angle: float, /) -> None: ...
315320
def rotate_y(self: _TVec, angle: float, /) -> _TVec: ...
316321
def rotate_y_rad(self: _TVec, angle: float, /) -> _TVec: ...
317322
def rotate_y_ip(self, angle: float, /) -> None: ...
318323
def rotate_y_rad_ip(self, angle: float, /) -> None: ...
324+
@deprecated("since 2.1.1. Use `pygame.Vector3.rotate_y_rad_ip` instead")
319325
def rotate_y_ip_rad(self, angle: float, /) -> None: ...
320326
def rotate_z(self: _TVec, angle: float, /) -> _TVec: ...
321327
def rotate_z_rad(self: _TVec, angle: float, /) -> _TVec: ...
322328
def rotate_z_ip(self, angle: float, /) -> None: ...
323329
def rotate_z_rad_ip(self, angle: float, /) -> None: ...
330+
@deprecated("since 2.1.1. Use `pygame.Vector3.rotate_z_rad_ip` instead")
324331
def rotate_z_ip_rad(self, angle: float, /) -> None: ...
325332
def as_spherical(self) -> Tuple[float, float, float]: ...
326333
def from_spherical(self, spherical: Tuple[float, float, float], /) -> None: ...
@@ -338,7 +345,7 @@ def invlerp(a: float, b: float, value: float, /) -> float: ...
338345
def remap(i_min: float, i_max: float, o_min: float, o_max: float, value: float, /) -> float: ...
339346
def smoothstep(a: float, b: float, weight: float, /) -> float: ...
340347

341-
342-
# typehints for deprecated functions, to be removed in a future version
348+
@deprecated("Functionality is removed")
343349
def enable_swizzling() -> None: ...
350+
@deprecated("Functionality is removed")
344351
def disable_swizzling() -> None: ...

0 commit comments

Comments
 (0)