Skip to content

Commit 4c0baa4

Browse files
committed
fix black formatting
Signed-off-by: Mike Stitt <[email protected]>
1 parent d06fe46 commit 4c0baa4

File tree

2 files changed

+28
-9
lines changed

2 files changed

+28
-9
lines changed

subprojects/robotpy-wpilib/tests/test_timedrobot.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from wpilib.timedrobotpy import _Callback
44

5+
56
def test_calcFutureExpirationUs() -> None:
67
cb = _Callback(func=None, periodUs=20_000, expirationUs=100)
78
assert cb.calcFutureExpirationUs(100) == 20_100
@@ -18,10 +19,23 @@ def test_calcFutureExpirationUs() -> None:
1819
assert cb.calcFutureExpirationUs(40_501) == 80_500
1920

2021
cb = _Callback(func=None, periodUs=1_000, expirationUs=0)
21-
assert cb.calcFutureExpirationUs(1_000_000_000_000_000_000) == 1_000_000_000_000_001_000
22-
assert cb.calcFutureExpirationUs(1_000_000_000_000_000_001) == 1_000_000_000_000_001_000
23-
assert cb.calcFutureExpirationUs(1_000_000_000_000_000_999) == 1_000_000_000_000_001_000
24-
assert cb.calcFutureExpirationUs(1_000_000_000_000_001_000) == 1_000_000_000_000_002_000
25-
assert cb.calcFutureExpirationUs(1_000_000_000_000_001_001) == 1_000_000_000_000_002_000
26-
27-
22+
assert (
23+
cb.calcFutureExpirationUs(1_000_000_000_000_000_000)
24+
== 1_000_000_000_000_001_000
25+
)
26+
assert (
27+
cb.calcFutureExpirationUs(1_000_000_000_000_000_001)
28+
== 1_000_000_000_000_001_000
29+
)
30+
assert (
31+
cb.calcFutureExpirationUs(1_000_000_000_000_000_999)
32+
== 1_000_000_000_000_001_000
33+
)
34+
assert (
35+
cb.calcFutureExpirationUs(1_000_000_000_000_001_000)
36+
== 1_000_000_000_000_002_000
37+
)
38+
assert (
39+
cb.calcFutureExpirationUs(1_000_000_000_000_001_001)
40+
== 1_000_000_000_000_002_000
41+
)

subprojects/robotpy-wpilib/wpilib/timedrobotpy.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,11 @@ def calcFutureExpirationUs(
7676
# and multiply that by self._periodUs to calculate how much time in full
7777
# periods we need to skip to catch up, and add that to the sum to calculate
7878
# when we should run again.
79-
return self.expirationUs + self._periodUs \
79+
return (
80+
self.expirationUs
81+
+ self._periodUs
8082
+ ((currentTimeUs - self.expirationUs) // self._periodUs) * self._periodUs
83+
)
8184

8285
def setNextStartTimeUs(self, currentTimeUs: microsecondsAsInt) -> None:
8386
self.expirationUs = self.calcFutureExpirationUs(currentTimeUs)
@@ -99,7 +102,9 @@ def add(self, item: Any) -> None:
99102
def pop(self) -> Any:
100103
return heappop(self._data)
101104

102-
def peek(self) -> Any: # todo change to Any | None when we don't build with python 3.9
105+
def peek(
106+
self,
107+
) -> Any: # todo change to Any | None when we don't build with python 3.9
103108
if self._data:
104109
return self._data[0]
105110
else:

0 commit comments

Comments
 (0)