Skip to content

Commit

Permalink
Some stub fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
gresm committed Dec 16, 2024
1 parent d2e8e72 commit afb8125
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
4 changes: 1 addition & 3 deletions buildconfig/stubs/pygame/event.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,14 @@ from pygame import Window, constants as _c

class Event(EventLike):
type: int
__dict__: dict[str, Any]
dict: dict[str, Any] # type: ignore

@overload
def __init__(
self, type: int, dict: Optional[Dict[str, Any]] = None, **kwargs: Any
) -> None: ...
@overload
def __init__(
self, dict: Optional[dict[str, Any]] = None, **kwargs: Any
self, dict: Optional[Dict[str, Any]] = None, **kwargs: Any
) -> None: ...

def __getattribute__(self, name: str) -> Any: ...
Expand Down
5 changes: 5 additions & 0 deletions src_py/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,11 @@ def __setattr__(self, name: str, value: Any):
def __delattr__(self, name: str) -> None:
del self._dict[name]

def __dir__(self):
ret = super().__dir__()
ret = (*ret, *self._dict.keys())
return ret


EventType = Event
_register_event_class(Event)
Expand Down
2 changes: 1 addition & 1 deletion test/time_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def test_multiple_timers(self):
set_time, set_dict, repeat, stop = events_tests_dict[event.type]
# measure time for each event, should almost match expected time
self.assertAlmostEqual(
(now_time - times[event.type]) * 1000, set_time, delta=6
(now_time - times[event.type]) * 1000, set_time, delta=8
)

# the dict attribute should be the same reference, if it exists
Expand Down

0 comments on commit afb8125

Please sign in to comment.