Skip to content

Commit 2c4161f

Browse files
committed
✨ linting and ⬛ ✨
1 parent be85a02 commit 2c4161f

File tree

1 file changed

+24
-16
lines changed

1 file changed

+24
-16
lines changed

arcade/future/sub_clock.py

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
from __future__ import annotations
2+
23
from typing import Optional, Union
34

4-
from arcade.clock import Clock, GLOBAL_CLOCK
5+
from arcade.clock import GLOBAL_CLOCK, Clock
6+
57

6-
def boot_strap_clock(clock: Optional[Clock] = None):
8+
def boot_strap_clock(clock: Optional[Clock] = None) -> Clock:
79
"""
810
Because the sub_clock is not a fully featured part of arcade we have to
911
manipulate the clocks before the can be used with sub_clocks.
@@ -19,22 +21,26 @@ def boot_strap_clock(clock: Optional[Clock] = None):
1921
"""
2022
clock = clock or GLOBAL_CLOCK
2123

22-
if hasattr(clock, 'children'):
23-
raise ValueError(f'The clock {clock} has already been bootstrapped.')
24+
if hasattr(clock, "children"):
25+
raise ValueError(f"The clock {clock} has already been bootstrapped.")
2426

25-
clock.children = [] # type: ignore -- No type check will ever like this, but we do what we must.
27+
# No type check will ever like this, but we do what we must.
28+
clock.children = [] # type: ignore
2629

2730
def recursive_tick(delta_time: float) -> None:
2831
clock.tick(delta_time)
29-
for child in clock.children: # type: ignore -- we know the clock will have .children
32+
for child in clock.children: # type: ignore
3033
child.tick(clock._tick_delta_time)
3134

32-
clock.tick = recursive_tick
35+
# Hey we did a decorator manually! what a time to be alive.
36+
clock.tick = recursive_tick # type: ignore
37+
38+
def add_child(child: SubClock) -> None:
39+
clock.children.append(child) # type: ignore
3340

34-
def add_child(child: SubClock):
35-
clock.children.append(child) # type: ignore -- we know the clock will have .children
41+
clock.add_child = add_child # type: ignore
3642

37-
clock.add_child = add_child # type: ignore -- we know the clock will have .children
43+
return clock
3844

3945

4046
class SubClock(Clock):
@@ -49,20 +55,22 @@ class SubClock(Clock):
4955
i.e. a value of 0.5 means time elapsed half as fast for this clock. Defaults to 1.0.
5056
"""
5157

52-
def __init__(self, parent: Union[Clock, SubClock, None] = None, tick_speed: float = 1):
58+
def __init__(self, parent: Union[Clock, SubClock, None] = None, tick_speed: float = 1) -> None:
5359
parent = parent or GLOBAL_CLOCK
5460
super().__init__(parent._elapsed_time, parent._tick, tick_speed)
5561
self.children: list[SubClock] = []
5662
try:
57-
parent.add_child(self) # type: ignore -- we know the clock will have .children (or if not we want it to yell)
63+
parent.add_child(self) # type: ignore
5864
except AttributeError:
59-
raise AttributeError(f'The clock {parent} has not been bootstrapped properly'
60-
f'call boot_strap_clock({parent}) before adding children')
65+
raise AttributeError(
66+
f"The clock {parent} has not been bootstrapped properly"
67+
f"call boot_strap_clock({parent}) before adding children"
68+
)
6169

62-
def add_child(self, child: SubClock):
70+
def add_child(self, child: SubClock) -> None:
6371
self.children.append(child)
6472

65-
def tick(self, delta_time: float):
73+
def tick(self, delta_time: float) -> None:
6674
super().tick(delta_time)
6775

6876
for child in self.children:

0 commit comments

Comments
 (0)