Skip to content

Commit 5e39de9

Browse files
committed
Various: assert that callables are such at time of use
1 parent 4fb19bf commit 5e39de9

8 files changed

+13
-0
lines changed

commands2/instantcommand.py

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def __init__(
2020
2121
:param toRun: the Runnable to run
2222
:param requirements: the subsystems required by this command"""
23+
assert toRun is None or callable(toRun)
2324
super().__init__(
2425
toRun or (lambda: None),
2526
lambda: None,

commands2/notifiercommand.py

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ def __init__(
2929
:param requirements: the subsystems required by this command"""
3030
super().__init__()
3131

32+
assert callable(toRun)
33+
3234
self.notifier = Notifier(toRun)
3335
self.period = period
3436
self.addRequirements(*requirements)

commands2/pidcommand.py

+3
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ def __init__(
3838
"""
3939
super().__init__()
4040

41+
assert callable(measurementSource)
42+
assert callable(useOutput)
43+
4144
self._controller = controller
4245
self._useOutput = useOutput
4346
self._measurement = measurementSource

commands2/proxycommand.py

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def __init__(self, *args, **kwargs):
3636
super().__init__()
3737

3838
def init_supplier(supplier: Callable[[], Command]):
39+
assert callable(supplier)
3940
self._supplier = supplier
4041

4142
def init_command(command: Command):

commands2/runcommand.py

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def __init__(self, toRun: Callable[[], Any], *requirements: Subsystem):
1919
2020
:param toRun: the Runnable to run
2121
:param requirements: the subsystems to require"""
22+
assert callable(toRun)
2223
super().__init__(
2324
lambda: None, toRun, lambda interrupted: None, lambda: False, *requirements
2425
)

commands2/selectcommand.py

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ def __init__(
2828
:param selector: the selector to determine which command to run"""
2929
super().__init__()
3030

31+
assert callable(selector)
32+
3133
self._commands = commands
3234
self._selector = selector
3335

commands2/startendcommand.py

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ def __init__(
2727
:param onInit: the Runnable to run on command init
2828
:param onEnd: the Runnable to run on command end
2929
:param requirements: the subsystems required by this command"""
30+
assert callable(onInit)
31+
assert callable(onEnd)
3032
super().__init__(
3133
onInit, lambda: None, lambda _: onEnd(), lambda: False, *requirements
3234
)

commands2/waituntilcommand.py

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ def __init__(self, *args, **kwargs):
3939
super().__init__()
4040

4141
def init_condition(condition: Callable[[], bool]) -> None:
42+
assert callable(condition)
4243
self._condition = condition
4344

4445
def init_time(time: float) -> None:

0 commit comments

Comments
 (0)