diff --git a/buildconfig/stubs/pygame/event.pyi b/buildconfig/stubs/pygame/event.pyi index 59fd6a52f5..174201fefd 100644 --- a/buildconfig/stubs/pygame/event.pyi +++ b/buildconfig/stubs/pygame/event.pyi @@ -6,8 +6,6 @@ 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__( @@ -15,7 +13,7 @@ class Event(EventLike): ) -> 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: ... diff --git a/src_py/event.py b/src_py/event.py index 5e1045d993..fb97f00c0e 100644 --- a/src_py/event.py +++ b/src_py/event.py @@ -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) diff --git a/test/time_test.py b/test/time_test.py index d996186e17..08e2d31e83 100644 --- a/test/time_test.py +++ b/test/time_test.py @@ -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