Skip to content

Commit 23df106

Browse files
authored
Update section __init__ type hints (#2527)
* Update section __init__ type hints * Update left, bottom, width, and height to hint that they accept int or float * fixes for the automated checks
1 parent 3c17eca commit 23df106

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

arcade/sections.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ class Section:
5656

5757
def __init__(
5858
self,
59-
left: int,
60-
bottom: int,
61-
width: int,
62-
height: int,
59+
left: int | float,
60+
bottom: int | float,
61+
width: int | float,
62+
height: int | float,
6363
*,
6464
name: str | None = None,
6565
accept_keyboard_keys: bool | Iterable = True,
@@ -116,19 +116,19 @@ def __init__(
116116
# section position into the current viewport
117117
# if screen is resized it's upto the user to move or resize each section
118118
# (section will receive on_resize event)
119-
self._left: int = left
120-
self._bottom: int = bottom
121-
self._width: int = width
122-
self._height: int = height
123-
self._right: int = left + width
124-
self._top: int = bottom + height
119+
self._left: int | float = left
120+
self._bottom: int | float = bottom
121+
self._width: int | float = width
122+
self._height: int | float = height
123+
self._right: int | float = left + width
124+
self._top: int | float = bottom + height
125125

126126
# section event capture dimensions
127127
# if section is modal, capture all events on the screen
128-
self._ec_left: int = 0 if self._modal else self._left
129-
self._ec_right: int = self.window.width if self._modal else self._right
130-
self._ec_bottom: int = 0 if self._modal else self._bottom
131-
self._ec_top: int = self.window.height if self._modal else self._top
128+
self._ec_left: int | float = 0 if self._modal else self._left
129+
self._ec_right: int | float = self.window.width if self._modal else self._right
130+
self._ec_bottom: int | float = 0 if self._modal else self._bottom
131+
self._ec_top: int | float = self.window.height if self._modal else self._top
132132

133133
self.camera: Projector | None = None
134134
"""optional section camera"""
@@ -180,7 +180,7 @@ def draw_order(self) -> int:
180180
return self._draw_order
181181

182182
@property
183-
def left(self) -> int:
183+
def left(self) -> int | float:
184184
"""Left edge of this section"""
185185
return self._left
186186

@@ -192,7 +192,7 @@ def left(self, value: int):
192192
self._ec_right = self.window.width if self._modal else self._right
193193

194194
@property
195-
def bottom(self) -> int:
195+
def bottom(self) -> int | float:
196196
"""The bottom edge of this section"""
197197
return self._bottom
198198

@@ -204,7 +204,7 @@ def bottom(self, value: int):
204204
self._ec_top = self.window.height if self._modal else self._top
205205

206206
@property
207-
def width(self) -> int:
207+
def width(self) -> int | float:
208208
"""The width of this section"""
209209
return self._width
210210

@@ -215,7 +215,7 @@ def width(self, value: int):
215215
self._ec_right = self.window.width if self._modal else self._right
216216

217217
@property
218-
def height(self) -> int:
218+
def height(self) -> int | float:
219219
"""The height of this section"""
220220
return self._height
221221

@@ -226,7 +226,7 @@ def height(self, value: int):
226226
self._ec_top = self.window.height if self._modal else self._top
227227

228228
@property
229-
def right(self) -> int:
229+
def right(self) -> int | float:
230230
"""Right edge of this section"""
231231
return self._right
232232

@@ -238,7 +238,7 @@ def right(self, value: int):
238238
self._ec_left = 0 if self._modal else self._left
239239

240240
@property
241-
def top(self) -> int:
241+
def top(self) -> int | float:
242242
"""Top edge of this section"""
243243
return self._top
244244

0 commit comments

Comments
 (0)