Remove deprecated code (#8656)

This commit is contained in:
Gold856
2026-03-15 00:28:31 -04:00
committed by GitHub
parent f1adce4cf7
commit d1fba06851
52 changed files with 10 additions and 1135 deletions

View File

@@ -307,26 +307,6 @@ public abstract class Command implements Sendable {
return new ParallelDeadlineGroup(deadline, this);
}
/**
* Decorates this command with a set of commands to run parallel to it, ending when the calling
* command ends and interrupting all the others. Often more convenient/less-verbose than
* constructing a new {@link ParallelDeadlineGroup} explicitly.
*
* <p>Note: This decorator works by adding this command to a composition. The command the
* decorator was called on cannot be scheduled independently or be added to a different
* composition (namely, decorators), unless it is manually cleared from the list of composed
* commands with {@link CommandScheduler#removeComposedCommand(Command)}. The command composition
* returned from this method can be further decorated without issue.
*
* @param parallel the commands to run in parallel
* @return the decorated command
* @deprecated Use {@link deadlineFor} instead.
*/
@Deprecated(since = "2025", forRemoval = true)
public ParallelDeadlineGroup deadlineWith(Command... parallel) {
return new ParallelDeadlineGroup(this, parallel);
}
/**
* Decorates this command with a set of commands to run parallel to it, ending when the calling
* command ends and interrupting all the others. Often more convenient/less-verbose than
@@ -535,16 +515,6 @@ public abstract class Command implements Sendable {
});
}
/**
* Schedules this command.
*
* @deprecated Use CommandScheduler.getInstance().schedule(Command...) instead
*/
@Deprecated(since = "2025", forRemoval = true)
public void schedule() {
CommandScheduler.getInstance().schedule(this);
}
/**
* Cancels this command. Will call {@link #end(boolean) end(true)}. Commands will be canceled
* regardless of {@link InterruptionBehavior interruption behavior}.

View File

@@ -24,24 +24,6 @@ public class ProxyCommand extends Command {
private final Supplier<Command> m_supplier;
private Command m_command;
/**
* Creates a new ProxyCommand that schedules the supplied command when initialized, and ends when
* it is no longer scheduled. Use this for lazily creating <strong>proxied</strong> commands at
* runtime. Proxying should only be done to escape from composition requirement semantics, so if
* only initialization time command construction is needed, use {@link DeferredCommand} instead.
*
* @param supplier the command supplier
* @deprecated This constructor's similarity to {@link DeferredCommand} is confusing and opens
* potential footguns for users who do not fully understand the semantics and implications of
* proxying, but who simply want runtime construction. Users who do know what they are doing
* and need a supplier-constructed proxied command should instead defer a proxy command.
* @see DeferredCommand
*/
@Deprecated(since = "2025", forRemoval = true)
public ProxyCommand(Supplier<Command> supplier) {
m_supplier = requireNonNullParam(supplier, "supplier", "ProxyCommand");
}
/**
* Creates a new ProxyCommand that schedules the given command when initialized, and ends when it
* is no longer scheduled.

View File

@@ -152,10 +152,6 @@ CommandPtr Command::WithName(std::string_view name) && {
return std::move(*this).ToPtr().WithName(name);
}
void Command::Schedule() {
CommandScheduler::GetInstance().Schedule(this);
}
void Command::Cancel() {
CommandScheduler::GetInstance().Cancel(this);
}

View File

@@ -176,15 +176,6 @@ CommandPtr CommandPtr::WithDeadline(CommandPtr&& deadline) && {
return std::move(*this);
}
CommandPtr CommandPtr::DeadlineWith(CommandPtr&& parallel) && {
AssertValid();
std::vector<std::unique_ptr<Command>> vec;
vec.emplace_back(std::move(parallel).Unwrap());
m_ptr =
std::make_unique<ParallelDeadlineGroup>(std::move(m_ptr), std::move(vec));
return std::move(*this);
}
CommandPtr CommandPtr::DeadlineFor(CommandPtr&& parallel) && {
AssertValid();
std::vector<std::unique_ptr<Command>> vec;
@@ -268,11 +259,6 @@ std::unique_ptr<Command> CommandPtr::Unwrap() && {
return std::move(m_ptr);
}
void CommandPtr::Schedule() const& {
AssertValid();
CommandScheduler::GetInstance().Schedule(*this);
}
void CommandPtr::Cancel() const& {
AssertValid();
CommandScheduler::GetInstance().Cancel(*this);

View File

@@ -21,7 +21,6 @@
#include "wpi/commands2/WaitCommand.hpp"
#include "wpi/commands2/WaitUntilCommand.hpp"
#include "wpi/util/FunctionExtras.hpp"
#include "wpi/util/deprecated.hpp"
using namespace wpi::cmd;

View File

@@ -9,23 +9,10 @@
#include <fmt/format.h>
#include "wpi/util/deprecated.hpp"
#include "wpi/util/sendable/SendableBuilder.hpp"
using namespace wpi::cmd;
WPI_IGNORE_DEPRECATED
ProxyCommand::ProxyCommand(wpi::util::unique_function<Command*()> supplier)
: m_supplier(std::move(supplier)) {}
ProxyCommand::ProxyCommand(wpi::util::unique_function<CommandPtr()> supplier)
: ProxyCommand([supplier = std::move(supplier),
holder = std::optional<CommandPtr>{}]() mutable {
holder = supplier();
return holder->get();
}) {}
WPI_UNIGNORE_DEPRECATED
ProxyCommand::ProxyCommand(Command* command)
: m_supplier([command] { return command; }) {
SetName(fmt::format("Proxy({})", command->GetName()));

View File

@@ -396,14 +396,6 @@ class Command : public wpi::util::Sendable,
*/
CommandPtr WithName(std::string_view name) &&;
/**
* Schedules this command.
*
* @deprecated Use CommandScheduler::GetInstance().Schedule() instead
*/
[[deprecated("Use CommandScheduler::GetInstance().Schedule() instead.")]]
void Schedule();
/**
* Cancels this command. Will call End(true). Commands will be canceled
* regardless of interruption behavior.

View File

@@ -179,18 +179,6 @@ class [[nodiscard]] CommandPtr final {
*/
CommandPtr WithDeadline(CommandPtr&& deadline) &&;
/**
* Decorates this command with a set of commands to run parallel to it, ending
* when the calling command ends and interrupting all the others. Often more
* convenient/less-verbose than constructing a new {@link
* ParallelDeadlineGroup} explicitly.
*
* @param parallel the commands to run in parallel
* @return the decorated command
*/
[[deprecated("Replace with DeadlineFor")]]
CommandPtr DeadlineWith(CommandPtr&& parallel) &&;
/**
* Decorates this command with a set of commands to run parallel to it, ending
* when the calling command ends and interrupting all the others. Often more
@@ -274,17 +262,6 @@ class [[nodiscard]] CommandPtr final {
*/
std::unique_ptr<Command> Unwrap() &&;
/**
* Schedules this command.
*
* @deprecated Use CommandScheduler::GetInstance().Schedule() instead
*/
[[deprecated("Use CommandScheduler::GetInstance().Schedule() instead.")]]
void Schedule() const&;
// Prevent calls on a temporary, as the returned pointer would be invalid
void Schedule() && = delete;
/**
* Cancels this command. Will call End(true). Commands will be canceled
* regardless of interruption behavior.

View File

@@ -15,7 +15,6 @@
#include "wpi/commands2/CommandPtr.hpp"
#include "wpi/commands2/Requirements.hpp"
#include "wpi/commands2/SelectCommand.hpp"
#include "wpi/util/deprecated.hpp"
namespace wpi::cmd {
class Subsystem;

View File

@@ -9,7 +9,6 @@
#include "wpi/commands2/Command.hpp"
#include "wpi/commands2/CommandHelper.hpp"
#include "wpi/util/FunctionExtras.hpp"
#include "wpi/util/deprecated.hpp"
namespace wpi::cmd {
/**
@@ -27,46 +26,6 @@ namespace wpi::cmd {
*/
class ProxyCommand : public CommandHelper<Command, ProxyCommand> {
public:
/**
* Creates a new ProxyCommand that schedules the supplied command when
* initialized, and ends when it is no longer scheduled. Use this for lazily
* creating <strong>proxied</strong> commands at runtime. Proxying should only
* be done to escape from composition requirement semantics, so if only
* initialization time command construction is needed, use {@link
* DeferredCommand} instead.
*
* @param supplier the command supplier
* @deprecated This constructor's similarity to {@link DeferredCommand} is
* confusing and opens potential footguns for users who do not fully
* understand the semantics and implications of proxying, but who simply want
* runtime construction. Users who do know what they are doing and need a
* supplier-constructed proxied command should instead defer a proxy command.
* @see DeferredCommand
*/
WPI_IGNORE_DEPRECATED
[[deprecated("Defer a proxy command instead.")]]
explicit ProxyCommand(wpi::util::unique_function<Command*()> supplier);
/**
* Creates a new ProxyCommand that schedules the supplied command when
* initialized, and ends when it is no longer scheduled. Use this for lazily
* creating <strong>proxied</strong> commands at runtime. Proxying should only
* be done to escape from composition requirement semantics, so if only
* initialization time command construction is needed, use {@link
* DeferredCommand} instead.
*
* @param supplier the command supplier
* @deprecated This constructor's similarity to {@link DeferredCommand} is
* confusing and opens potential footguns for users who do not fully
* understand the semantics and implications of proxying, but who simply want
* runtime construction. Users who do know what they are doing and need a
* supplier-constructed proxied command should instead defer a proxy command.
* @see DeferredCommand
*/
[[deprecated("Defer a proxy command instead.")]]
explicit ProxyCommand(wpi::util::unique_function<CommandPtr()> supplier);
WPI_UNIGNORE_DEPRECATED
/**
* Creates a new ProxyCommand that schedules the given command when
* initialized, and ends when it is no longer scheduled.

View File

@@ -59,16 +59,3 @@ __all__ = [
"WaitUntilCommand",
"WrapperCommand",
]
if not TYPE_CHECKING:
def __getattr__(attr):
if attr == "SubsystemBase":
import warnings
warnings.warn(
"SubsystemBase is deprecated", DeprecationWarning, stacklevel=2
)
return Subsystem
raise AttributeError(f"module {__name__!r} has no attribute {attr!r}")

View File

@@ -260,35 +260,6 @@ class Command(Sendable):
return SequentialCommandGroup(self, *next)
def deadlineWith(self, *parallel: Command) -> ParallelDeadlineGroup:
"""
Decorates this command with a set of commands to run parallel to it, ending when the calling
command ends and interrupting all the others. Often more convenient/less-verbose than
constructing a new ParallelDeadlineGroup explicitly.
.. note:: This decorator works by adding this command to a composition.
The command the decorator was called on cannot be scheduled
independently or be added to a different composition (namely,
decorators), unless it is manually cleared from the list of composed
commands with :func:`commands2.CommandScheduler.removeComposedCommand`.
The command composition returned from this method can be further
decorated without issue.
:param parallel: the commands to run in parallel
:returns: the decorated command
"""
import warnings
warnings.warn(
"deadlineWith is deprecated use deadlineFor instead",
DeprecationWarning,
stacklevel=2,
)
from .paralleldeadlinegroup import ParallelDeadlineGroup
return ParallelDeadlineGroup(self, *parallel)
def deadlineFor(self, *parallel: Command) -> ParallelDeadlineGroup:
"""
Decorates this command with a set of commands to run parallel to it, ending when the calling

View File

@@ -1,13 +1,9 @@
# validated: 2024-01-19 DS 192a28af4731 ProxyCommand.java
from __future__ import annotations
from typing import Callable, overload
from wpiutil import SendableBuilder
from .command import Command
from .util import format_args_kwargs
import warnings
class ProxyCommand(Command):
@@ -21,26 +17,8 @@ class ProxyCommand(Command):
If this command is interrupted, it will cancel the command.
"""
_supplier: Callable[[], Command]
_command: Command
@overload
def __init__(self, supplier: Callable[[], Command]):
"""
Creates a new ProxyCommand that schedules the supplied command when initialized, and ends when
it is no longer scheduled. Use this for lazily creating **proxied** commands at
runtime. Proxying should only be done to escape from composition requirement semantics, so if
only initialization time command construction is needed, use DeferredCommand instead.
:param supplier: the command supplier
This constructor's similarity to DeferredCommand is confusing and opens
potential footguns for users who do not fully understand the semantics and implications of
proxying, but who simply want runtime construction. Users who do know what they are doing
and need a supplier-constructed proxied command should instead proxy a DeferredCommand
using the ``asProxy`` decorator.
"""
...
@overload
def __init__(self, command: Command):
"""
Creates a new ProxyCommand that schedules the given command when initialized, and ends when it
@@ -48,47 +26,12 @@ class ProxyCommand(Command):
:param command: the command to run by proxy
"""
...
def __init__(self, *args, **kwargs):
super().__init__()
def init_supplier(supplier: Callable[[], Command]):
assert callable(supplier)
self._supplier = supplier
warnings.warn(
"The ProxyCommand supplier constructor has been deprecated",
DeprecationWarning,
stacklevel=3,
)
def init_command(command: Command):
self.setName(f"Proxy({command.getName()})")
self._supplier = lambda: command
num_args = len(args) + len(kwargs)
if num_args == 1 and len(kwargs) == 1:
if "supplier" in kwargs:
return init_supplier(kwargs["supplier"])
elif "command" in kwargs:
return init_command(kwargs["command"])
elif num_args == 1 and len(args) == 1:
if isinstance(args[0], Command):
return init_command(args[0])
elif callable(args[0]):
return init_supplier(args[0])
raise TypeError(f"""
TypeError: ProxyCommand(): incompatible function arguments. The following argument types are supported:
1. (self: ProxyCommand, supplier: () -> Command)
2. (self: ProxyCommand, command: Command)
Invoked with: {format_args_kwargs(self, *args, **kwargs)}
""")
self.setName(f"Proxy({command.getName()})")
self._command = command
def initialize(self):
self._command = self._supplier()
self._command.schedule()
def end(self, interrupted: bool):

View File

@@ -78,24 +78,6 @@ def test_andThen(scheduler: commands2.CommandScheduler):
assert condition == True
def test_deadlineWith(scheduler: commands2.CommandScheduler):
condition = OOBoolean(False)
condition.set(False)
dictator = commands2.WaitUntilCommand(condition)
endsBefore = commands2.InstantCommand()
endsAfter = commands2.WaitUntilCommand(lambda: False)
group = dictator.deadlineWith(endsBefore, endsAfter)
scheduler.schedule(group)
scheduler.run()
assert group.isScheduled()
condition.set(True)
scheduler.run()
assert not group.isScheduled()
def test_deadlineFor(scheduler: commands2.CommandScheduler):
condition = OOBoolean(False)
condition.set(False)