Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FunctionalCommand: Assert lifecycle functions are callable #48

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions commands2/functionalcommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ class FunctionalCommand(Command):
A command that allows the user to pass in functions for each of the basic command methods through
the constructor. Useful for inline definitions of complex commands - note, however, that if a
command is beyond a certain complexity it is usually better practice to write a proper class for
it than to inline it."""
it than to inline it.
"""

def __init__(
self,
Expand All @@ -29,9 +30,15 @@ def __init__(
:param onExecute: the function to run on command execution
:param onEnd: the function to run on command end
:param isFinished: the function that determines whether the command has finished
:param requirements: the subsystems required by this command"""
:param requirements: the subsystems required by this command
"""
super().__init__()

assert callable(onInit)
assert callable(onExecute)
assert callable(onEnd)
assert callable(isFinished)

self._onInit = onInit
self._onExecute = onExecute
self._onEnd = onEnd
Expand Down