Skip to content

Commit 13a2131

Browse files
committed
ruff
1 parent b93e3d5 commit 13a2131

62 files changed

Lines changed: 800 additions & 800 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/add_widgets.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def change_background_color(selected_value, color, **kwargs):
6868
print('Change widget color to', value_tuple[0]) # selected_value format ('Color', surface, color)
6969
if color == (-1, -1, -1): # Generate a random color
7070
color = (randrange(0, 255), randrange(0, 255), randrange(0, 255))
71-
widget: 'pygame_menu.widgets.Selector' = kwargs.get('widget')
71+
widget: pygame_menu.widgets.Selector = kwargs.get('widget')
7272
widget.update_font({'selected_color': color})
7373
widget.get_selection_effect().color = color
7474

@@ -252,7 +252,7 @@ def open_link(*args) -> None:
252252
"""
253253
Opens link.
254254
"""
255-
link: 'pygame_menu.widgets.MenuLink' = args[-1]
255+
link: pygame_menu.widgets.MenuLink = args[-1]
256256
link.open()
257257

258258

pygame_menu/_base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def __repr__(self) -> str:
6363

6464
return sup_repr
6565

66-
def _update__repr___(self, obj: 'Base') -> None:
66+
def _update__repr___(self, obj: Base) -> None:
6767
"""
6868
Update __repr__ from other Base object.
6969
@@ -72,7 +72,7 @@ def _update__repr___(self, obj: 'Base') -> None:
7272
self._class_id__repr__ = obj._class_id__repr__
7373
self._id__repr__ = obj._id__repr__
7474

75-
def set_attribute(self, key: str, value: Any = None) -> 'Base':
75+
def set_attribute(self, key: str, value: Any = None) -> Base:
7676
"""
7777
Set an attribute.
7878
@@ -147,7 +147,7 @@ def has_attribute(self, key: str) -> bool:
147147

148148
return self._attributes is not None and key in self._attributes
149149

150-
def remove_attribute(self, key: str) -> 'Base':
150+
def remove_attribute(self, key: str) -> Base:
151151
"""
152152
Removes the given attribute from the object. Throws ``IndexError`` if
153153
the given key does not exist.

pygame_menu/_decorator.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -65,18 +65,18 @@ class Decorator(Base):
6565
str, tuple[int, int, Union[tuple[Tuple2NumberType, ...], Tuple2NumberType]]] # centerx, centery, coords
6666
_cache_last_status: dict[str, tuple[int, int, int, int, int, int]]
6767
_cache_needs_update: dict[str, bool]
68-
_cache_surface: dict[str, Optional['pygame.Surface']]
68+
_cache_surface: dict[str, Optional[pygame.Surface]]
6969
_decor: dict[str, list[tuple[int, str, Any]]] # type, id, data
7070
_decor_enabled: dict[str, bool]
7171
_decor_prev_id: list[str]
72-
_obj: Union['pygame_menu.widgets.Widget', 'pygame_menu._scrollarea.ScrollArea', 'pygame_menu.Menu']
72+
_obj: Union[pygame_menu.widgets.Widget, pygame_menu._scrollarea.ScrollArea, pygame_menu.Menu]
7373
_post_enabled: bool
7474
_prev_enabled: bool
7575
cache: bool
7676

7777
def __init__(
7878
self,
79-
obj: Union['pygame_menu.widgets.Widget', 'pygame_menu._scrollarea.ScrollArea', 'pygame_menu.Menu'],
79+
obj: Union[pygame_menu.widgets.Widget, pygame_menu._scrollarea.ScrollArea, pygame_menu.Menu],
8080
decorator_id: str = '',
8181
verbose: bool = True
8282
) -> None:
@@ -112,15 +112,15 @@ def __init__(
112112
self._cache_needs_update = {DECOR_TYPE_PREV: False, DECOR_TYPE_POST: False}
113113
self._cache_surface = {DECOR_TYPE_PREV: None, DECOR_TYPE_POST: None}
114114

115-
def __copy__(self) -> 'Decorator':
115+
def __copy__(self) -> Decorator:
116116
"""
117117
Copy method.
118118
119119
:return: Raises copy exception
120120
"""
121121
raise _DecoratorCopyException('Decorator class cannot be copied')
122122

123-
def __deepcopy__(self, memodict: dict[int, Any]) -> 'Decorator':
123+
def __deepcopy__(self, memodict: dict[int, Any]) -> Decorator:
124124
"""
125125
Deep-copy method.
126126
@@ -180,7 +180,7 @@ def _total_decor(self) -> int:
180180
"""
181181
return len(self._decor[DECOR_TYPE_PREV]) + len(self._decor[DECOR_TYPE_POST])
182182

183-
def force_cache_update(self, prev: Optional[bool] = None) -> 'Decorator':
183+
def force_cache_update(self, prev: Optional[bool] = None) -> Decorator:
184184
"""
185185
Forces cache update.
186186
@@ -396,7 +396,7 @@ def add_surface(
396396
self,
397397
x: NumberType,
398398
y: NumberType,
399-
surface: 'pygame.Surface',
399+
surface: pygame.Surface,
400400
prev: bool = True,
401401
centered: bool = False,
402402
**kwargs
@@ -427,7 +427,7 @@ def add_baseimage(
427427
self,
428428
x: NumberType,
429429
y: NumberType,
430-
image: 'pygame_menu.BaseImage',
430+
image: pygame_menu.BaseImage,
431431
prev: bool = True,
432432
centered: bool = False,
433433
**kwargs
@@ -463,7 +463,7 @@ def add_rect(
463463
self,
464464
x: NumberType,
465465
y: NumberType,
466-
rect: 'pygame.Rect',
466+
rect: pygame.Rect,
467467
color: ColorInputType,
468468
width: int = 0,
469469
prev: bool = True,
@@ -639,7 +639,7 @@ def add_pixel(
639639

640640
def add_callable(
641641
self,
642-
fun: Union[Callable[['pygame.Surface', Any], Any], CallableNoArgsType],
642+
fun: Union[Callable[[pygame.Surface, Any], Any], CallableNoArgsType],
643643
prev: bool = True,
644644
pass_args: bool = True
645645
) -> str:
@@ -672,7 +672,7 @@ def add_callable(
672672
def add_textured_polygon(
673673
self,
674674
coords: Union[list[Tuple2NumberType], tuple[Tuple2NumberType, ...]],
675-
texture: Union['pygame.Surface', 'pygame_menu.BaseImage'],
675+
texture: Union[pygame.Surface, pygame_menu.BaseImage],
676676
tx: int = 0,
677677
ty: int = 0,
678678
prev: bool = True,
@@ -811,7 +811,7 @@ def add_vline(
811811
assert y1 != y2
812812
return self.add_line((x, y1), (x, y2), color, width, prev, **kwargs)
813813

814-
def disable(self, decorid: str) -> 'Decorator':
814+
def disable(self, decorid: str) -> Decorator:
815815
"""
816816
Disable a certain decoration from ID. Raises ``IndexError`` if decoration was
817817
not found.
@@ -825,7 +825,7 @@ def disable(self, decorid: str) -> 'Decorator':
825825
self.force_cache_update(prev=decorid in self._decor_prev_id)
826826
return self
827827

828-
def enable(self, decorid: str) -> 'Decorator':
828+
def enable(self, decorid: str) -> Decorator:
829829
"""
830830
Enable a certain decoration from ID. Raises ``IndexError`` if decoration
831831
was not found.
@@ -851,7 +851,7 @@ def is_enabled(self, decorid: str) -> bool:
851851
raise IndexError(f'decoration<"{decorid}"> was not found')
852852
return self._decor_enabled[decorid]
853853

854-
def remove(self, decorid: str) -> 'Decorator':
854+
def remove(self, decorid: str) -> Decorator:
855855
"""
856856
Remove a decoration from a given ID. Raises ``IndexError`` if decoration
857857
was not found.
@@ -873,7 +873,7 @@ def remove(self, decorid: str) -> 'Decorator':
873873
return self
874874
raise IndexError(f'decoration<"{decorid}"> was not found')
875875

876-
def remove_all(self, prev: Optional[bool] = None) -> 'Decorator':
876+
def remove_all(self, prev: Optional[bool] = None) -> Decorator:
877877
"""
878878
Remove all decorations.
879879
@@ -894,7 +894,7 @@ def _draw_assemble_cache(
894894
self,
895895
prev: str,
896896
deco: list[tuple[int, str, Any]],
897-
surface: 'pygame.Surface'
897+
surface: pygame.Surface
898898
) -> None:
899899
"""
900900
Draw cache, assemble if needed.
@@ -931,7 +931,7 @@ def _draw_assemble_cache(
931931

932932
surface.blit(self._cache_surface[prev], (0, 0))
933933

934-
def draw_prev(self, surface: 'pygame.Surface') -> 'Decorator':
934+
def draw_prev(self, surface: pygame.Surface) -> Decorator:
935935
"""
936936
Draw prev.
937937
@@ -944,7 +944,7 @@ def draw_prev(self, surface: 'pygame.Surface') -> 'Decorator':
944944
self._draw_assemble_cache(DECOR_TYPE_PREV, self._decor[DECOR_TYPE_PREV], surface)
945945
return self
946946

947-
def draw_post(self, surface: 'pygame.Surface') -> 'Decorator':
947+
def draw_post(self, surface: pygame.Surface) -> Decorator:
948948
"""
949949
Draw post.
950950
@@ -957,7 +957,7 @@ def draw_post(self, surface: 'pygame.Surface') -> 'Decorator':
957957
self._draw_assemble_cache(DECOR_TYPE_POST, self._decor[DECOR_TYPE_POST], surface)
958958
return self
959959

960-
def _draw(self, deco: list[tuple[int, str, Any]], surface: 'pygame.Surface') -> None:
960+
def _draw(self, deco: list[tuple[int, str, Any]], surface: pygame.Surface) -> None:
961961
"""
962962
Draw.
963963
@@ -1055,7 +1055,7 @@ def _draw(self, deco: list[tuple[int, str, Any]], surface: 'pygame.Surface') ->
10551055
surface.fill(data, rect)
10561056

10571057
elif dtype == DECORATION_RECT:
1058-
d_rect: 'pygame.Rect'
1058+
d_rect: pygame.Rect
10591059
pos, d_rect, color, width, kwargs = data
10601060
pos = self._update_pos_list(rect, decoid, pos, **kwargs)[0]
10611061
d_rect = d_rect.copy()
@@ -1078,7 +1078,7 @@ def _draw(self, deco: list[tuple[int, str, Any]], surface: 'pygame.Surface') ->
10781078

10791079
def _update_pos_list(
10801080
self,
1081-
rect: 'pygame.Rect',
1081+
rect: pygame.Rect,
10821082
decoid: str,
10831083
pos: Union[Tuple2NumberType, tuple[Tuple2NumberType, ...]], # only (x, y) or ((x1,y1), ...
10841084
use_center_positioning=True

0 commit comments

Comments
 (0)