Skip to content

Commit 65bb565

Browse files
committed
Mark old types deprecated: don't duplicate event
1 parent 19e29f4 commit 65bb565

File tree

1 file changed

+9
-25
lines changed

1 file changed

+9
-25
lines changed

buildconfig/stubs/pygame/event.pyi

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@ from typing_extensions import deprecated # added in 3.13
33

44
from pygame.typing import SequenceLike
55

6-
@final
7-
class Event:
8-
# Event fields here duplicated below into EventType because Event is
9-
# marked as final and can't be subclassed like the other xType aliases
10-
# are to allow @deprecated.
6+
class _GenericEvent:
7+
# Just exists to avoid duplication of data for Event
8+
# and (deprecated) EventType
119

1210
@property
1311
def type(self) -> int: ...
@@ -27,27 +25,13 @@ class Event:
2725
def dict(self) -> dict[str, Any]: ...
2826

2927
@final
30-
@deprecated("Use `Event` instead (this is an old alias)")
31-
class EventType:
32-
# Duplicated Event fields here because it is marked as final and can't be
33-
# subclassed like the other xType aliases are to allow @deprecated.
34-
35-
@property
36-
def type(self) -> int: ...
37-
__dict__: dict[str, Any]
38-
__hash__: None # type: ignore
39-
def __init__(
40-
self, type: int, dict: dict[str, Any] = ..., **kwargs: Any
41-
) -> None: ...
42-
def __getattribute__(self, name: str) -> Any: ...
43-
def __setattr__(self, name: str, value: Any) -> None: ...
44-
def __delattr__(self, name: str) -> None: ...
45-
def __bool__(self) -> bool: ...
28+
class Event(_GenericEvent):
29+
pass
4630

47-
# this is at the bottom because mypy complains if this declaration comes
48-
# before any uses of the dict[] typehinting because of the same naming
49-
@property
50-
def dict(self) -> dict[str, Any]: ...
31+
@final
32+
@deprecated("Use `Event` instead (this is an old alias)")
33+
class EventType(_GenericEvent):
34+
pass
5135

5236
_EventTypes = Union[int, SequenceLike[int]]
5337

0 commit comments

Comments
 (0)