Skip to content

Commit

Permalink
Mark old types deprecated: don't duplicate event
Browse files Browse the repository at this point in the history
  • Loading branch information
Starbuck5 committed Jan 24, 2025
1 parent 05325a9 commit 5fb1dd3
Showing 1 changed file with 9 additions and 25 deletions.
34 changes: 9 additions & 25 deletions buildconfig/stubs/pygame/event.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ from typing_extensions import deprecated # added in 3.13

from pygame.typing import SequenceLike

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

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

@final
@deprecated("Use `Event` instead (this is an old alias)")
class EventType:
# Duplicated Event fields here because it is marked as final and can't be
# subclassed like the other xType aliases are to allow @deprecated.

@property
def type(self) -> int: ...
__dict__: dict[str, Any]
__hash__: None # type: ignore
def __init__(
self, type: int, dict: dict[str, Any] = ..., **kwargs: Any
) -> None: ...
def __getattribute__(self, name: str) -> Any: ...
def __setattr__(self, name: str, value: Any) -> None: ...
def __delattr__(self, name: str) -> None: ...
def __bool__(self) -> bool: ...
class Event(_GenericEvent):
pass

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

_EventTypes = Union[int, SequenceLike[int]]

Expand Down

0 comments on commit 5fb1dd3

Please sign in to comment.