Skip to content

Commit fe73346

Browse files
committed
Deprecate deadlineWith tand add deadlineFor instead
From wpilibsuite/allwpilib#6544
1 parent 6dd95d7 commit fe73346

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

Diff for: commands2/command.py

+29
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,35 @@ def deadlineWith(self, *parallel: Command) -> ParallelDeadlineGroup:
266266
command ends and interrupting all the others. Often more convenient/less-verbose than
267267
constructing a new ParallelDeadlineGroup explicitly.
268268
269+
.. note:: This decorator works by adding this command to a composition.
270+
The command the decorator was called on cannot be scheduled
271+
independently or be added to a different composition (namely,
272+
decorators), unless it is manually cleared from the list of composed
273+
commands with :func:`commands2.CommandScheduler.removeComposedCommand`.
274+
The command composition returned from this method can be further
275+
decorated without issue.
276+
277+
:param parallel: the commands to run in parallel
278+
:returns: the decorated command
279+
"""
280+
import warnings
281+
282+
warnings.warn(
283+
"deadlineWith is deprecated use deadlineFor instead",
284+
DeprecationWarning,
285+
stacklevel=2,
286+
)
287+
288+
from .paralleldeadlinegroup import ParallelDeadlineGroup
289+
290+
return ParallelDeadlineGroup(self, *parallel)
291+
292+
def deadlineFor(self, *parallel: Command) -> ParallelDeadlineGroup:
293+
"""
294+
Decorates this command with a set of commands to run parallel to it, ending when the calling
295+
command ends and interrupting all the others. Often more convenient/less-verbose than
296+
constructing a new ParallelDeadlineGroup explicitly.
297+
269298
.. note:: This decorator works by adding this command to a composition.
270299
The command the decorator was called on cannot be scheduled
271300
independently or be added to a different composition (namely,

0 commit comments

Comments
 (0)