Skip to content

Commit de27ca5

Browse files
committed
Trigger: pass loop to new Trigger in composition functions
1 parent 9ec9148 commit de27ca5

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

.gittrack

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[git-source-track]
22
upstream_root = ../allwpilib/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command
33
upstream_branch = main
4-
upstream_commit = 4b94a64b06057c723d6fcafeb1a45f55a70d179a
4+
upstream_commit = 25ad6eafd5eeaf57ed25db2414a20838bf098399
55
validation_root = commands2
66

commands2/button/trigger.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# validated: 2024-01-23 DS 70b60e3a7465 button/Trigger.java
1+
# validated: 2024-04-02 DS 0b1345946950 button/Trigger.java
22
from types import SimpleNamespace
33
from typing import Callable, overload
44

@@ -227,7 +227,7 @@ def __bool__(self) -> bool:
227227

228228
def __and__(self, other: Callable[[], bool]) -> "Trigger":
229229
assert callable(other)
230-
return Trigger(lambda: self() and other())
230+
return Trigger(self._loop, lambda: self() and other())
231231

232232
def and_(self, other: Callable[[], bool]) -> "Trigger":
233233
"""
@@ -240,7 +240,7 @@ def and_(self, other: Callable[[], bool]) -> "Trigger":
240240

241241
def __or__(self, other: Callable[[], bool]) -> "Trigger":
242242
assert callable(other)
243-
return Trigger(lambda: self() or other())
243+
return Trigger(self._loop, lambda: self() or other())
244244

245245
def or_(self, other: Callable[[], bool]) -> "Trigger":
246246
"""
@@ -252,7 +252,7 @@ def or_(self, other: Callable[[], bool]) -> "Trigger":
252252
return self | other
253253

254254
def __invert__(self) -> "Trigger":
255-
return Trigger(lambda: not self())
255+
return Trigger(self._loop, lambda: not self())
256256

257257
def negate(self) -> "Trigger":
258258
"""
@@ -280,4 +280,4 @@ def debounce(
280280
:returns: The debounced trigger.
281281
"""
282282
debouncer = Debouncer(seconds, debounce_type)
283-
return Trigger(lambda: debouncer.calculate(self()))
283+
return Trigger(self._loop, lambda: debouncer.calculate(self()))

0 commit comments

Comments
 (0)