Skip to content

Commit

Permalink
typing(gui):remove type ignores from gui (#2346)
Browse files Browse the repository at this point in the history
* remove type ignores from gui
  • Loading branch information
eruvanos committed Aug 8, 2024
1 parent f44233c commit 83cb72d
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
6 changes: 3 additions & 3 deletions arcade/gui/constructs.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def __init__(
raise ValueError("At least a single value has to be available for `buttons`")

super().__init__(size_hint=(1, 1))
self.register_event_type("on_action") # type: ignore # https://github.com/pyglet/pyglet/pull/1173 # noqa
self.register_event_type("on_action")

space = 20

Expand Down Expand Up @@ -135,7 +135,7 @@ def __init__(
space_between=space_between,
**kwargs,
)
self.register_event_type("on_action") # type: ignore # https://github.com/pyglet/pyglet/pull/1173 # noqa
self.register_event_type("on_action")

self.button_factory = button_factory

Expand All @@ -154,7 +154,7 @@ def add_button(
multiline: Whether the button is multiline or not.
"""
button = self.button_factory(text=label, style=style, multiline=multiline)
button.on_click = self._on_click # type: ignore
button.on_click = self._on_click
self.add(button)
return button

Expand Down
10 changes: 5 additions & 5 deletions arcade/gui/property.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,13 +312,13 @@ def __delitem__(self, key):
self.dispatch()

@override
def __iadd__(self, *args): # type: ignore
def __iadd__(self, *args):
list.__iadd__(self, *args)
self.dispatch()
return self

@override
def __imul__(self, *args): # type: ignore
def __imul__(self, *args):
list.__imul__(self, *args)
self.dispatch()
return self
Expand Down Expand Up @@ -373,7 +373,7 @@ def reverse(self):
self.dispatch()


class ListProperty(Property):
class ListProperty(Property, Generic[P]):
"""Property that represents a list.
Only list are allowed. Any other classes are forbidden.
Expand All @@ -383,7 +383,7 @@ def __init__(self):
super().__init__(default_factory=_ObservableList)

@override
def set(self, instance, value: dict):
def set(self, instance, value: list):
"""Set value for owner instance, wraps the list into an observable list."""
value = _ObservableList(self, instance, value) # type: ignore
value = _ObservableList(self, instance, value)
super().set(instance, value)
6 changes: 3 additions & 3 deletions arcade/gui/ui_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,11 +405,11 @@ def on_mouse_scroll(self, x, y, scroll_x, scroll_y):

def on_key_press(self, symbol: int, modifiers: int):
"""Converts key press event to UI event and dispatches it."""
return self.dispatch_ui_event(UIKeyPressEvent(self, symbol, modifiers)) # type: ignore
return self.dispatch_ui_event(UIKeyPressEvent(self, symbol, modifiers))

def on_key_release(self, symbol: int, modifiers: int):
"""Converts key release event to UI event and dispatches it."""
return self.dispatch_ui_event(UIKeyReleaseEvent(self, symbol, modifiers)) # type: ignore
return self.dispatch_ui_event(UIKeyReleaseEvent(self, symbol, modifiers))

def on_text(self, text):
"""Converts text event to UI event and dispatches it."""
Expand Down Expand Up @@ -442,7 +442,7 @@ def on_resize(self, width, height):
self.trigger_render()

@property
def rect(self) -> Rect: # type: ignore
def rect(self) -> Rect:
"""The rect of the UIManager, which is the window size."""
return LBWH(0, 0, *self.window.get_size())

Expand Down
6 changes: 3 additions & 3 deletions arcade/gui/widgets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ def __init__(
self.size_hint_min = size_hint_min
self.size_hint_max = size_hint_max

self.register_event_type("on_event") # type: ignore # https://github.com/pyglet/pyglet/pull/1173 # noqa
self.register_event_type("on_update") # type: ignore # https://github.com/pyglet/pyglet/pull/1173 # noqa
self.register_event_type("on_event")
self.register_event_type("on_update")

for child in children:
self.add(child)
Expand Down Expand Up @@ -558,7 +558,7 @@ def __init__(
size_hint_max=size_hint_max,
**kwargs,
)
self.register_event_type("on_click") # type: ignore
self.register_event_type("on_click")

self.interaction_buttons = interaction_buttons

Expand Down
2 changes: 1 addition & 1 deletion arcade/gui/widgets/dropdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def __init__(
# add children after super class setup
self.add(self._default_button)

self.register_event_type("on_change") # type: ignore # https://github.com/pyglet/pyglet/pull/1173 # noqa
self.register_event_type("on_change")

self.with_border(color=arcade.color.RED)

Expand Down
2 changes: 1 addition & 1 deletion arcade/gui/widgets/slider.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def __init__(
bind(self, "pressed", self.trigger_render)
bind(self, "disabled", self.trigger_render)

self.register_event_type("on_change") # type: ignore # https://github.com/pyglet/pyglet/pull/1173 # noqa
self.register_event_type("on_change")

def _x_for_value(self, value: float):
"""Provides the x coordinate for the given value."""
Expand Down
2 changes: 1 addition & 1 deletion arcade/gui/widgets/toggle.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def __init__(
)

self.value = value
self.register_event_type("on_change") # type: ignore # https://github.com/pyglet/pyglet/pull/1173 # noqa
self.register_event_type("on_change")

bind(self, "value", self.trigger_render)
bind(self, "value", self._dispatch_on_change_event)
Expand Down

0 comments on commit 83cb72d

Please sign in to comment.