Skip to content

Commit 6004b99

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

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

Diff for: commands2/command.py

+28
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,34 @@ 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+
warnings.warn(
282+
"deadlineWith is deprecated use deadlineFor instead",
283+
DeprecationWarning,
284+
stacklevel=2,
285+
)
286+
287+
from .paralleldeadlinegroup import ParallelDeadlineGroup
288+
289+
return ParallelDeadlineGroup(self, *parallel)
290+
291+
def deadlineFor(self, *parallel: Command) -> ParallelDeadlineGroup:
292+
"""
293+
Decorates this command with a set of commands to run parallel to it, ending when the calling
294+
command ends and interrupting all the others. Often more convenient/less-verbose than
295+
constructing a new ParallelDeadlineGroup explicitly.
296+
269297
.. note:: This decorator works by adding this command to a composition.
270298
The command the decorator was called on cannot be scheduled
271299
independently or be added to a different composition (namely,

0 commit comments

Comments
 (0)