diff --git a/.github/workflows/dist.yml b/.github/workflows/dist.yml index 30385adec..557ea77a9 100644 --- a/.github/workflows/dist.yml +++ b/.github/workflows/dist.yml @@ -208,7 +208,6 @@ jobs: - "macos-15" # arm64 - "windows-2025" python_version: - - '3.11' - '3.12' - '3.13' - '3.14' diff --git a/devtools/ci.py b/devtools/ci.py index dc0c63a7e..ad2a5d61e 100644 --- a/devtools/ci.py +++ b/devtools/ci.py @@ -4,10 +4,8 @@ import subprocess import sys -import typing as T import click -from packaging.requirements import Requirement from packaging.version import Version from .ctx import Context @@ -105,7 +103,7 @@ def build_other_wheels(ctx: Context, no_test: bool): @click.option("--buildtype", help="meson build type (debug, release, etc)") @click.pass_obj def build_meson_wheels( - ctx: Context, no_test: bool, cross: T.Optional[str], buildtype: T.Optional[str] + ctx: Context, no_test: bool, cross: str | None, buildtype: str | None ): """ Builds wheels that use meson, runs tests. diff --git a/devtools/ci_check_wpistructs.py b/devtools/ci_check_wpistructs.py index ee37aef2c..33f0a237c 100644 --- a/devtools/ci_check_wpistructs.py +++ b/devtools/ci_check_wpistructs.py @@ -26,7 +26,7 @@ def _normalize_cpp_type(type_name: str) -> str: return " ".join(type_name.split()) -def _find_struct_specializations(text: str) -> T.List[str]: +def _find_struct_specializations(text: str) -> list[str]: """Find concrete wpi::util::Struct specializations in C++ text.""" types = [] for match in _STRUCT_SPECIALIZATION_RE.finditer(text): @@ -43,7 +43,7 @@ def _find_struct_specializations(text: str) -> T.List[str]: def _struct_header_to_owner_header( header: pathlib.Path, include_root: pathlib.Path -) -> T.Optional[str]: +) -> str | None: """Map wpi/foo/struct/BarStruct.hpp to wpi/foo/Bar.hpp.""" rel_parts = header.relative_to(include_root).parts if len(rel_parts) < 2 or rel_parts[-2] != "struct": @@ -65,7 +65,7 @@ def _has_setup_wpistruct(yaml_path: pathlib.Path, type_name: str) -> bool: return f"SetupWPyStruct<{compact_type}>" in compact -def _native_include_roots(project) -> T.List[pathlib.Path]: +def _native_include_roots(project) -> list[pathlib.Path]: native_root = project.path / "src" / "native" if not native_root.exists(): return [] @@ -83,9 +83,9 @@ def _iter_native_headers(include_root: pathlib.Path) -> T.Iterator[pathlib.Path] def _collect_wpistruct_checks( ctx: Context, -) -> T.List[T.Tuple[str, pathlib.Path, str, pathlib.Path, bool]]: - checks: T.List[T.Tuple[str, pathlib.Path, str, pathlib.Path, bool]] = [] - seen: T.Set[T.Tuple[str, pathlib.Path, str, pathlib.Path]] = set() +) -> list[tuple[str, pathlib.Path, str, pathlib.Path, bool]]: + checks: list[tuple[str, pathlib.Path, str, pathlib.Path, bool]] = [] + seen: set[tuple[str, pathlib.Path, str, pathlib.Path]] = set() for project in ctx.subprojects.values(): if not getattr(project, "is_semiwrap_project", lambda: False)(): @@ -152,7 +152,7 @@ def _collect_wpistruct_checks( def _collect_missing_wpistructs( ctx: Context, -) -> T.List[T.Tuple[str, pathlib.Path, str, pathlib.Path]]: +) -> list[tuple[str, pathlib.Path, str, pathlib.Path]]: return [ (project_name, yaml_path, type_name, struct_header) for project_name, yaml_path, type_name, struct_header, found in _collect_wpistruct_checks( diff --git a/devtools/config.py b/devtools/config.py index 6e0ed1d48..2243ce363 100644 --- a/devtools/config.py +++ b/devtools/config.py @@ -1,6 +1,5 @@ import dataclasses import tomlkit -import typing as T from .util import parse_input @@ -26,29 +25,29 @@ class Parameters: mrclib_bin_version: str mrclib_bin_url: str - mrclib_artifacts: T.Set[str] + mrclib_artifacts: set[str] #: semiwrap name_transform known_words shared by all wrapper projects - known_words: T.List[str] + known_words: list[str] #: renames [project.entry-points.KEY*] to [project.entry-points.VALUE] - entrypoints: T.Dict[str, str] + entrypoints: dict[str, str] - exclude_artifacts: T.Set[str] + exclude_artifacts: set[str] - requirements: T.Dict[str, str] + requirements: dict[str, str] robot_wheel_platform: str @dataclasses.dataclass class UpdateConfig: - py_versions: T.Dict[str, str] + py_versions: dict[str, str] params: Parameters - subprojects: T.Dict[str, SubprojectConfig] + subprojects: dict[str, SubprojectConfig] -def load(fname) -> T.Tuple[UpdateConfig, tomlkit.TOMLDocument]: +def load(fname) -> tuple[UpdateConfig, tomlkit.TOMLDocument]: with open(fname) as fp: cfgdata = tomlkit.parse(fp.read()) diff --git a/devtools/ctx.py b/devtools/ctx.py index 6ba26acf5..ddaf97ad0 100644 --- a/devtools/ctx.py +++ b/devtools/ctx.py @@ -3,7 +3,6 @@ import subprocess import sys import sysconfig -import typing as T import toposort @@ -30,7 +29,7 @@ def __init__(self, verbose: bool) -> None: self.wheel_path = self.root_path / "dist" self.other_wheel_path = self.root_path / "dist-other" - subprojects: T.List[Subproject] = [] + subprojects: list[Subproject] = [] for project, cfg in self.cfg.subprojects.items(): # Skip projects that aren't compatible with the robot if self.is_robot and not cfg.robot: diff --git a/devtools/examples.py b/devtools/examples.py index 9c518910e..b0de52de2 100644 --- a/devtools/examples.py +++ b/devtools/examples.py @@ -32,8 +32,8 @@ def _validate_example_list(root: pathlib.Path, expected_dirs: T.Sequence[str]) - @dataclasses.dataclass class ExamplesTests: - base: T.List[str] - ignored: T.List[str] + base: list[str] + ignored: list[str] @dataclasses.dataclass diff --git a/devtools/pyproject.py b/devtools/pyproject.py index 4bffed308..652763325 100644 --- a/devtools/pyproject.py +++ b/devtools/pyproject.py @@ -135,10 +135,10 @@ def _render(self, name: str) -> RenderedProject: text = tomlkit.dumps(data) return RenderedProject(path, path.parent / "pyproject.toml", data, text) - def render_all(self) -> T.Dict[str, RenderedProject]: + def render_all(self) -> dict[str, RenderedProject]: return {name: self._render(name) for name in self.cfg.subprojects} - def validate_templates(self) -> T.List[str]: + def validate_templates(self) -> list[str]: errors = [] def check(path, field, actual, expected): diff --git a/devtools/subproject.py b/devtools/subproject.py index 1bf2a70a1..d5984305e 100644 --- a/devtools/subproject.py +++ b/devtools/subproject.py @@ -59,7 +59,7 @@ def is_native_project(self) -> bool: # Tasks # - def _config_settings(self, config_settings: T.List[str]) -> T.List[str]: + def _config_settings(self, config_settings: list[str]) -> list[str]: if sys.platform == "win32" and self.is_meson_project(): config_settings = config_settings + [ "setup-args=-Dcpp_std=none", @@ -68,7 +68,7 @@ def _config_settings(self, config_settings: T.List[str]) -> T.List[str]: return config_settings - def develop(self, buildtype: str, jobs: T.Optional[int] = None): + def develop(self, buildtype: str, jobs: int | None = None): config_settings = [f"setup-args=-Dbuildtype={buildtype}"] if jobs is not None: @@ -154,7 +154,7 @@ def build_wheel( wheel_path: pathlib.Path, other_wheel_path: pathlib.Path, install: bool, - config_settings: T.List[str], + config_settings: list[str], ): wheel_path.mkdir(parents=True, exist_ok=True) diff --git a/devtools/util.py b/devtools/util.py index 6615ad620..3f48bc8a1 100644 --- a/devtools/util.py +++ b/devtools/util.py @@ -1,6 +1,5 @@ import shlex import subprocess -import sys import typing from validobj import errors @@ -37,7 +36,7 @@ def _convert_validation_error(fname, ve: errors.ValidationError) -> ValidationEr return ValidationError(vmsg) -def parse_input(value: typing.Any, spec: typing.Type[T], fname) -> T: +def parse_input(value: typing.Any, spec: type[T], fname) -> T: try: return validobj.validation.parse_input(value, spec) except errors.ValidationError as ve: diff --git a/examples/check_header.py b/examples/check_header.py index 66e39e34b..689eb6cba 100755 --- a/examples/check_header.py +++ b/examples/check_header.py @@ -9,7 +9,7 @@ def check_file_content(file_path): - with open(file_path, "r") as file: + with open(file_path) as file: lines = file.readlines() if file.name.endswith("robot.py"): diff --git a/examples/robot/ArcadeDrive/robot.py b/examples/robot/ArcadeDrive/robot.py index fc5a72589..f5dc48b61 100755 --- a/examples/robot/ArcadeDrive/robot.py +++ b/examples/robot/ArcadeDrive/robot.py @@ -5,6 +5,8 @@ # the WPILib BSD license file in the root directory of this project. # +from typing import override + import wpilib import wpilib_drivers @@ -29,6 +31,7 @@ def __init__(self): # gearbox is constructed, you might have to invert the left side instead. right_motor.set_inverted(True) + @override def teleop_periodic(self): # Drive with arcade drive. # That means that the Y axis drives forward diff --git a/examples/robot/ArcadeDriveXboxController/robot.py b/examples/robot/ArcadeDriveXboxController/robot.py index df5f5c813..7b267d93d 100755 --- a/examples/robot/ArcadeDriveXboxController/robot.py +++ b/examples/robot/ArcadeDriveXboxController/robot.py @@ -5,6 +5,8 @@ # the WPILib BSD license file in the root directory of this project. # +from typing import override + import wpilib import wpilib_drivers @@ -29,6 +31,7 @@ def __init__(self): # gearbox is constructed, you might have to invert the left side instead. right_motor.set_inverted(True) + @override def teleop_periodic(self): # Drive with split arcade style # That means that the Y axis of the left stick moves forward diff --git a/examples/robot/ArmSimulation/robot.py b/examples/robot/ArmSimulation/robot.py index 94999768e..072ca22a4 100755 --- a/examples/robot/ArmSimulation/robot.py +++ b/examples/robot/ArmSimulation/robot.py @@ -5,6 +5,8 @@ # the WPILib BSD license file in the root directory of this project. # +from typing import override + import wpilib from constants import Constants @@ -19,12 +21,15 @@ def __init__(self) -> None: self.arm = Arm() self.joystick = wpilib.Joystick(Constants.JOYSTICK_PORT) + @override def simulation_periodic(self) -> None: self.arm.simulation_periodic() + @override def teleop_init(self) -> None: self.arm.load_preferences() + @override def teleop_periodic(self) -> None: if self.joystick.get_trigger(): # Here, we run PID control like normal. @@ -33,6 +38,7 @@ def teleop_periodic(self) -> None: # Otherwise, we disable the motor. self.arm.stop() + @override def disabled_init(self) -> None: # This just makes sure that our simulation code knows that the motor's off. self.arm.stop() diff --git a/examples/robot/DSGamepadChooser/robot.py b/examples/robot/DSGamepadChooser/robot.py index 01bbc03ac..d4f91a4ef 100644 --- a/examples/robot/DSGamepadChooser/robot.py +++ b/examples/robot/DSGamepadChooser/robot.py @@ -5,8 +5,10 @@ # the WPILib BSD license file in the root directory of this project. # -from hal import RobotMode +from typing import override + import wpilib +from hal import RobotMode from wpilib.opmodes import OpModeRobot @@ -28,15 +30,18 @@ def __init__(self) -> None: self.delay = 0 self.speed = 0.25 - def disabledPeriodic(self) -> None: + @override + def disabled_periodic(self) -> None: self.chooser.update() wpilib.DriverStationDisplay.update_lines() + @override def start(self) -> None: self.target = self.chooser.get_selected("Target") self.delay = self.chooser.get_selected_integer("Delay") self.speed = self.chooser.get_selected_double("Speed") + @override def periodic(self) -> None: wpilib.DriverStationDisplay.add_data("Selected Auto", "Score") wpilib.DriverStationDisplay.add_data("Target", self.target) @@ -59,15 +64,18 @@ def __init__(self) -> None: self.attempts = 1 self.turnScale = 0.5 - def disabledPeriodic(self) -> None: + @override + def disabled_periodic(self) -> None: self.chooser.update() wpilib.DriverStationDisplay.update_lines() + @override def start(self) -> None: self.approach = self.chooser.get_selected("Approach") self.attempts = self.chooser.get_selected_integer("Attempts") self.turnScale = self.chooser.get_selected_double("Turn Scale") + @override def periodic(self) -> None: wpilib.DriverStationDisplay.add_data("Selected Auto", "Balance") wpilib.DriverStationDisplay.add_data("Approach", self.approach) diff --git a/examples/robot/DifferentialDriveBot/robot.py b/examples/robot/DifferentialDriveBot/robot.py index 7af124fd9..1990cd182 100755 --- a/examples/robot/DifferentialDriveBot/robot.py +++ b/examples/robot/DifferentialDriveBot/robot.py @@ -5,6 +5,8 @@ # the WPILib BSD license file in the root directory of this project. # +from typing import override + import wpimath import wpilib @@ -22,10 +24,12 @@ def __init__(self) -> None: self.velocity_limiter = wpimath.SlewRateLimiter(3) self.rot_limiter = wpimath.SlewRateLimiter(3) + @override def autonomous_periodic(self) -> None: self.teleop_periodic() self.drive.update_odometry() + @override def teleop_periodic(self) -> None: # Get the x velocity. We are inverting this because Xbox controllers return # negative values when we push forward. diff --git a/examples/robot/DifferentialDrivePoseEstimator/robot.py b/examples/robot/DifferentialDrivePoseEstimator/robot.py index 8c7e5226b..ff83401de 100644 --- a/examples/robot/DifferentialDrivePoseEstimator/robot.py +++ b/examples/robot/DifferentialDrivePoseEstimator/robot.py @@ -5,6 +5,8 @@ # the WPILib BSD license file in the root directory of this project. # +from typing import override + import ntcore import wpilib import wpimath @@ -26,16 +28,20 @@ def __init__(self) -> None: self.velocity_limiter = wpimath.SlewRateLimiter(3) self.rot_limiter = wpimath.SlewRateLimiter(3) + @override def autonomous_periodic(self) -> None: self.teleop_periodic() self.drive.update_odometry() + @override def simulation_periodic(self) -> None: self.drive.simulation_periodic() + @override def robot_periodic(self) -> None: self.drive.periodic() + @override def teleop_periodic(self) -> None: # Get the x velocity. We are inverting this because Xbox controllers return # negative values when we push forward. diff --git a/examples/robot/DriveDistanceOffboard/constants.py b/examples/robot/DriveDistanceOffboard/constants.py index d43a4e363..95646ca55 100644 --- a/examples/robot/DriveDistanceOffboard/constants.py +++ b/examples/robot/DriveDistanceOffboard/constants.py @@ -10,8 +10,6 @@ changes. """ -import math - class DriveConstants: DT = 0.02 diff --git a/examples/robot/DriveDistanceOffboard/examplesmartmotorcontroller.py b/examples/robot/DriveDistanceOffboard/examplesmartmotorcontroller.py index 31fcb919d..3f9244047 100644 --- a/examples/robot/DriveDistanceOffboard/examplesmartmotorcontroller.py +++ b/examples/robot/DriveDistanceOffboard/examplesmartmotorcontroller.py @@ -4,7 +4,6 @@ # the WPILib BSD license file in the root directory of this project. # -import wpilib import enum diff --git a/examples/robot/DriveDistanceOffboard/robot.py b/examples/robot/DriveDistanceOffboard/robot.py index a747c8b3c..9cdb9f280 100644 --- a/examples/robot/DriveDistanceOffboard/robot.py +++ b/examples/robot/DriveDistanceOffboard/robot.py @@ -5,9 +5,8 @@ # the WPILib BSD license file in the root directory of this project. # -import typing +from typing import override -import wpilib import commands2 import commands2.cmd @@ -33,18 +32,21 @@ def __init__(self) -> None: initialization code. """ super().__init__() - self.autonomous_command: typing.Optional[commands2.Command] = None + self.autonomous_command: commands2.Command | None = None # Instantiate our RobotContainer. This will perform all our button bindings, and put our # autonomous chooser on the dashboard. self.container = robotcontainer.RobotContainer() + @override def disabled_init(self) -> None: """This function is called once each time the robot enters Disabled mode.""" + @override def disabled_periodic(self) -> None: """This function is called periodically when disabled""" + @override def autonomous_init(self) -> None: """This autonomous runs the autonomous command selected by your RobotContainer class.""" self.autonomous_command = self.container.get_autonomous_command() @@ -55,9 +57,11 @@ def autonomous_init(self) -> None: else: print("no auto command?") + @override def autonomous_periodic(self) -> None: """This function is called periodically during autonomous""" + @override def teleop_init(self) -> None: # This makes sure that the autonomous stops running when # teleop starts running. If you want the autonomous to @@ -66,9 +70,11 @@ def teleop_init(self) -> None: if self.autonomous_command is not None: self.autonomous_command.cancel() + @override def teleop_periodic(self) -> None: """This function is called periodically during operator control""" + @override def utility_init(self) -> None: # Cancels all running commands at the start of utility mode commands2.CommandScheduler.get_instance().cancel_all() diff --git a/examples/robot/DutyCycleEncoder/robot.py b/examples/robot/DutyCycleEncoder/robot.py index 6fb14dc8d..f7313bf05 100755 --- a/examples/robot/DutyCycleEncoder/robot.py +++ b/examples/robot/DutyCycleEncoder/robot.py @@ -10,6 +10,8 @@ an arm or elevator. """ +from typing import override + import telemetry import wpilib import wpimath @@ -44,6 +46,7 @@ def __init__(self): # much more stable. self.duty_cycle_encoder.set_assumed_frequency(967.8) + @override def robot_periodic(self): # Connected can be checked, and uses the frequency of the encoder connected = self.duty_cycle_encoder.is_connected() diff --git a/examples/robot/ElevatorExponentialProfile/robot.py b/examples/robot/ElevatorExponentialProfile/robot.py index 375f1def4..5a61b4a5f 100644 --- a/examples/robot/ElevatorExponentialProfile/robot.py +++ b/examples/robot/ElevatorExponentialProfile/robot.py @@ -5,6 +5,8 @@ # the WPILib BSD license file in the root directory of this project. # +from typing import override + import wpilib import wpimath @@ -32,6 +34,7 @@ def __init__(self) -> None: # Note: These gains are fake, and will have to be tuned for your robot. self.motor.set_pid(1.3, 0.0, 0.7) + @override def teleop_periodic(self) -> None: if self.joystick.get_raw_button_pressed(2): self.goal = wpimath.ExponentialProfile.State(5, 0) diff --git a/examples/robot/ElevatorExponentialSimulation/robot.py b/examples/robot/ElevatorExponentialSimulation/robot.py index 9697ab33c..b67d8f799 100644 --- a/examples/robot/ElevatorExponentialSimulation/robot.py +++ b/examples/robot/ElevatorExponentialSimulation/robot.py @@ -5,6 +5,8 @@ # the WPILib BSD license file in the root directory of this project. # +from typing import override + import wpilib import constants @@ -19,17 +21,21 @@ def __init__(self) -> None: self.joystick = wpilib.Joystick(constants.JOYSTICK_PORT) self.elevator = Elevator() + @override def robot_periodic(self) -> None: # Update the telemetry, including mechanism visualization, regardless of mode. self.elevator.update_telemetry() + @override def simulation_periodic(self) -> None: # Update the simulation model. self.elevator.simulation_periodic() + @override def teleop_init(self) -> None: self.elevator.reset() + @override def teleop_periodic(self) -> None: if self.joystick.get_trigger(): # Here, we set the constant setpoint of 10 meters. @@ -38,6 +44,7 @@ def teleop_periodic(self) -> None: # Otherwise, we update the setpoint to 1 meter. self.elevator.reach_goal(constants.LOWERK_SETPOINT) + @override def disabled_init(self) -> None: # This just makes sure that our simulation code knows that the motor's off. self.elevator.stop() diff --git a/examples/robot/ElevatorProfiledPID/robot.py b/examples/robot/ElevatorProfiledPID/robot.py index 1e9d4b024..e483b396d 100644 --- a/examples/robot/ElevatorProfiledPID/robot.py +++ b/examples/robot/ElevatorProfiledPID/robot.py @@ -6,6 +6,7 @@ # import math +from typing import override import wpilib import wpilib_drivers @@ -41,6 +42,7 @@ def __init__(self) -> None: self.encoder.set_distance_per_pulse(1 / 360 * 2 * math.pi * 1.5) + @override def teleop_periodic(self) -> None: if self.joystick.get_raw_button_pressed(2): self.controller.set_goal(5) diff --git a/examples/robot/ElevatorSimulation/robot.py b/examples/robot/ElevatorSimulation/robot.py index 02acbe413..1bb45958e 100755 --- a/examples/robot/ElevatorSimulation/robot.py +++ b/examples/robot/ElevatorSimulation/robot.py @@ -5,6 +5,8 @@ # the WPILib BSD license file in the root directory of this project. # +from typing import override + import wpilib import constants @@ -19,14 +21,17 @@ def __init__(self) -> None: self.joystick = wpilib.Joystick(constants.JOYSTICK_PORT) self.elevator = Elevator() + @override def robot_periodic(self) -> None: # Update the telemetry, including mechanism visualization, regardless of mode. self.elevator.update_telemetry() + @override def simulation_periodic(self) -> None: # Update the simulation model. self.elevator.simulation_periodic() + @override def teleop_periodic(self) -> None: if self.joystick.get_trigger(): # Here, we set the constant setpoint of 0.75 meters. @@ -35,6 +40,7 @@ def teleop_periodic(self) -> None: # Otherwise, we update the setpoint to 0. self.elevator.reach_goal(0.0) + @override def disabled_init(self) -> None: # This just makes sure that our simulation code knows that the motor's off. self.elevator.stop() diff --git a/examples/robot/ElevatorTrapezoidProfile/examplesmartmotorcontroller.py b/examples/robot/ElevatorTrapezoidProfile/examplesmartmotorcontroller.py index e4d86f3ce..7ce349faf 100644 --- a/examples/robot/ElevatorTrapezoidProfile/examplesmartmotorcontroller.py +++ b/examples/robot/ElevatorTrapezoidProfile/examplesmartmotorcontroller.py @@ -4,8 +4,10 @@ # the WPILib BSD license file in the root directory of this project. # -import wpilib import enum +from typing import override + +import wpilib class ExampleSmartMotorController(wpilib.MotorController): @@ -79,18 +81,23 @@ def reset_encoder(self) -> None: """Resets the encoder to zero distance.""" pass - def set_throttle(self, velocity: float) -> None: - self._velocity = -velocity if self._inverted else velocity + @override + def set_throttle(self, throttle: float) -> None: + self._velocity = -throttle if self._inverted else throttle + @override def get_throttle(self) -> float: return self._velocity + @override def set_inverted(self, is_inverted: bool) -> None: self._inverted = is_inverted + @override def get_inverted(self) -> bool: return self._inverted + @override def disable(self) -> None: self._velocity = 0.0 diff --git a/examples/robot/ElevatorTrapezoidProfile/robot.py b/examples/robot/ElevatorTrapezoidProfile/robot.py index 94b396d45..1ae279f63 100644 --- a/examples/robot/ElevatorTrapezoidProfile/robot.py +++ b/examples/robot/ElevatorTrapezoidProfile/robot.py @@ -5,6 +5,8 @@ # the WPILib BSD license file in the root directory of this project. # +from typing import override + import wpilib from wpimath import TrapezoidProfile @@ -32,6 +34,7 @@ def __init__(self): # Note: These gains are fake, and will have to be tuned for your robot. self.motor.set_pid(1.3, 0.0, 0.7) + @override def teleop_periodic(self): if self.joystick.get_raw_button_pressed(2): self.goal = TrapezoidProfile.State(5, 0) diff --git a/examples/robot/Encoder/robot.py b/examples/robot/Encoder/robot.py index f4e44eee6..ff33e57f6 100755 --- a/examples/robot/Encoder/robot.py +++ b/examples/robot/Encoder/robot.py @@ -5,6 +5,8 @@ # the WPILib BSD license file in the root directory of this project. # +from typing import override + import telemetry import wpilib @@ -37,6 +39,7 @@ def __init__(self): # and that we want to measure distance in inches. self.encoder.set_distance_per_pulse(1.0 / 360.0 * 2.0 * math.pi * 1.5) + @override def teleop_periodic(self): telemetry.log("Encoder Distance", self.encoder.get_distance()) telemetry.log("Encoder Rate", self.encoder.get_rate()) diff --git a/examples/robot/ExpansionHubSample/opmodes/default_auto_mode.py b/examples/robot/ExpansionHubSample/opmodes/default_auto_mode.py index 6cdae02e2..84c76f899 100644 --- a/examples/robot/ExpansionHubSample/opmodes/default_auto_mode.py +++ b/examples/robot/ExpansionHubSample/opmodes/default_auto_mode.py @@ -2,7 +2,7 @@ # Open Source Software; you can modify and/or share it under the terms of # the WPILib BSD license file in the root directory of this project. -from typing import TYPE_CHECKING +from typing import TYPE_CHECKING, override import wpilib @@ -17,10 +17,12 @@ def __init__(self, robot: "Robot") -> None: self.robot = robot self.timer = wpilib.Timer() + @override def start(self) -> None: self.timer.reset() self.timer.start() + @override def periodic(self) -> None: if self.timer.get() < 2.0: self.robot.motor0.set_throttle(0.5) diff --git a/examples/robot/ExpansionHubSample/opmodes/default_tele_mode.py b/examples/robot/ExpansionHubSample/opmodes/default_tele_mode.py index f8dcfe4a6..884e81691 100644 --- a/examples/robot/ExpansionHubSample/opmodes/default_tele_mode.py +++ b/examples/robot/ExpansionHubSample/opmodes/default_tele_mode.py @@ -2,7 +2,7 @@ # Open Source Software; you can modify and/or share it under the terms of # the WPILib BSD license file in the root directory of this project. -from typing import TYPE_CHECKING +from typing import TYPE_CHECKING, override import wpilib @@ -17,6 +17,7 @@ def __init__(self, robot: "Robot") -> None: self.robot = robot self.gamepad = wpilib.DriverStation.get_gamepad(0) + @override def periodic(self) -> None: self.robot.motor0.set_throttle(-self.gamepad.get_left_y()) self.robot.motor1.set_throttle(-self.gamepad.get_right_y()) diff --git a/examples/robot/GettingStarted/robot.py b/examples/robot/GettingStarted/robot.py index a179ca1f1..ada89a5ca 100755 --- a/examples/robot/GettingStarted/robot.py +++ b/examples/robot/GettingStarted/robot.py @@ -5,6 +5,8 @@ # the WPILib BSD license file in the root directory of this project. # +from typing import override + import wpilib import wpilib_drivers @@ -27,10 +29,12 @@ def __init__(self): # gearbox is constructed, you might have to invert the left side instead. self.right_drive.set_inverted(True) + @override def autonomous_init(self): """This function is run once each time the robot enters autonomous mode.""" self.timer.restart() + @override def autonomous_periodic(self): """This function is called periodically during autonomous.""" @@ -41,17 +45,21 @@ def autonomous_periodic(self): else: self.robot_drive.arcade_drive(0, 0) # Stop robot + @override def teleop_init(self): """This function is called once each time the robot enters teleoperated mode.""" + @override def teleop_periodic(self): """This function is called periodically during teleoperated mode.""" self.robot_drive.arcade_drive( -self.controller.get_left_y(), -self.controller.get_right_x() ) + @override def utility_init(self): """This function is called once each time the robot enters utility mode.""" + @override def utility_periodic(self): """This function is called periodically during utility mode.""" diff --git a/examples/robot/Gyro/robot.py b/examples/robot/Gyro/robot.py index c13b2f4a0..e64768670 100755 --- a/examples/robot/Gyro/robot.py +++ b/examples/robot/Gyro/robot.py @@ -5,6 +5,8 @@ # the WPILib BSD license file in the root directory of this project. # +from typing import override + import wpilib import wpilib_drivers @@ -39,6 +41,7 @@ def __init__(self) -> None: # gearbox is constructed, you might have to invert the left side instead. self.right_drive.set_inverted(True) + @override def teleop_periodic(self) -> None: # The motor velocity is set from the joystick while the DifferentialDrive turning value is assigned # from the error between the setpoint and the gyro angle. diff --git a/examples/robot/HatchbotInlined/robot.py b/examples/robot/HatchbotInlined/robot.py index c2980efb0..8d2d15f37 100644 --- a/examples/robot/HatchbotInlined/robot.py +++ b/examples/robot/HatchbotInlined/robot.py @@ -5,7 +5,7 @@ # the WPILib BSD license file in the root directory of this project. # -import typing +from typing import override import commands2 import wpilib @@ -19,7 +19,7 @@ class MyRobot(commands2.TimedCommandRobot): has an implementation of robot_periodic which runs the scheduler for you """ - autonomous_command: typing.Optional[commands2.Command] = None + autonomous_command: commands2.Command | None = None def __init__(self) -> None: """ @@ -39,16 +39,20 @@ def __init__(self) -> None: # Change to `false` to not record joystick data. wpilib.DriverStation.start_data_log(wpilib.DataLogManager.get_log(), True) + @override def robot_periodic(self) -> None: super().robot_periodic() self.container.update_telemetry() + @override def disabled_init(self) -> None: """This function is called once each time the robot enters Disabled mode.""" + @override def disabled_periodic(self) -> None: """This function is called periodically when disabled""" + @override def autonomous_init(self) -> None: """This autonomous runs the autonomous command selected by your RobotContainer class.""" self.autonomous_command = self.container.get_autonomous_command() @@ -56,9 +60,11 @@ def autonomous_init(self) -> None: if self.autonomous_command: self.autonomous_command.schedule() + @override def autonomous_periodic(self) -> None: """This function is called periodically during autonomous""" + @override def teleop_init(self) -> None: # This makes sure that the autonomous stops running when # teleop starts running. If you want the autonomous to @@ -67,9 +73,11 @@ def teleop_init(self) -> None: if self.autonomous_command: self.autonomous_command.cancel() + @override def teleop_periodic(self) -> None: """This function is called periodically during operator control""" + @override def utility_init(self) -> None: # Cancels all running commands at the start of utility mode commands2.CommandScheduler.get_instance().cancel_all() diff --git a/examples/robot/HatchbotInlined/robotcontainer.py b/examples/robot/HatchbotInlined/robotcontainer.py index 81152eaaa..4351952fa 100644 --- a/examples/robot/HatchbotInlined/robotcontainer.py +++ b/examples/robot/HatchbotInlined/robotcontainer.py @@ -6,7 +6,6 @@ import telemetry import tunables -import wpilib import commands2 import commands2.button diff --git a/examples/robot/HatchbotInlined/subsystems/drivesubsystem.py b/examples/robot/HatchbotInlined/subsystems/drivesubsystem.py index 55f4b260b..9ba9e5063 100644 --- a/examples/robot/HatchbotInlined/subsystems/drivesubsystem.py +++ b/examples/robot/HatchbotInlined/subsystems/drivesubsystem.py @@ -4,6 +4,8 @@ # the WPILib BSD license file in the root directory of this project. # +from typing import override + import commands2 import telemetry import wpilib @@ -70,6 +72,7 @@ def set_max_output(self, max_output: float): """ self.drive.set_max_output(max_output) + @override def log_to(self, table: telemetry.TelemetryTable) -> None: super().log_to(table) table.log("leftDistance", self.left_encoder.get_distance()) diff --git a/examples/robot/HatchbotInlined/subsystems/hatchsubsystem.py b/examples/robot/HatchbotInlined/subsystems/hatchsubsystem.py index a36034aa5..e220fc136 100644 --- a/examples/robot/HatchbotInlined/subsystems/hatchsubsystem.py +++ b/examples/robot/HatchbotInlined/subsystems/hatchsubsystem.py @@ -4,6 +4,8 @@ # the WPILib BSD license file in the root directory of this project. # +from typing import override + import telemetry import wpilib import commands2 @@ -33,6 +35,7 @@ def release_hatch(self) -> commands2.Command: lambda: self.hatch_solenoid.set(wpilib.DoubleSolenoid.Value.REVERSE), self ) + @override def log_to(self, table: telemetry.TelemetryTable) -> None: super().log_to(table) table.log( diff --git a/examples/robot/HatchbotTraditional/commands/defaultdrive.py b/examples/robot/HatchbotTraditional/commands/defaultdrive.py index 56b00703f..f1075f7ce 100644 --- a/examples/robot/HatchbotTraditional/commands/defaultdrive.py +++ b/examples/robot/HatchbotTraditional/commands/defaultdrive.py @@ -4,6 +4,8 @@ # the WPILib BSD license file in the root directory of this project. # +from typing import override + import typing import commands2 from subsystems.drivesubsystem import DriveSubsystem @@ -23,5 +25,6 @@ def __init__( self.add_requirements(self.drive) + @override def execute(self) -> None: self.drive.arcade_drive(self.forward(), self.rotation()) diff --git a/examples/robot/HatchbotTraditional/commands/drivedistance.py b/examples/robot/HatchbotTraditional/commands/drivedistance.py index f747f9f88..12fe54bc1 100644 --- a/examples/robot/HatchbotTraditional/commands/drivedistance.py +++ b/examples/robot/HatchbotTraditional/commands/drivedistance.py @@ -4,6 +4,8 @@ # the WPILib BSD license file in the root directory of this project. # +from typing import override + import commands2 from subsystems.drivesubsystem import DriveSubsystem @@ -16,15 +18,19 @@ def __init__(self, inches: float, velocity: float, drive: DriveSubsystem) -> Non self.drive = drive self.add_requirements(drive) + @override def initialize(self) -> None: self.drive.reset_encoders() self.drive.arcade_drive(self.velocity, 0) + @override def execute(self) -> None: self.drive.arcade_drive(self.velocity, 0) + @override def end(self, interrupted: bool) -> None: self.drive.arcade_drive(0, 0) + @override def is_finished(self) -> bool: return abs(self.drive.get_average_encoder_distance()) >= self.distance diff --git a/examples/robot/HatchbotTraditional/commands/grabhatch.py b/examples/robot/HatchbotTraditional/commands/grabhatch.py index 6adfd18b1..d54f63643 100644 --- a/examples/robot/HatchbotTraditional/commands/grabhatch.py +++ b/examples/robot/HatchbotTraditional/commands/grabhatch.py @@ -4,6 +4,8 @@ # the WPILib BSD license file in the root directory of this project. # +from typing import override + import commands2 from subsystems.hatchsubsystem import HatchSubsystem @@ -13,8 +15,10 @@ def __init__(self, hatch: HatchSubsystem) -> None: self.hatch = hatch self.add_requirements(hatch) + @override def initialize(self) -> None: self.hatch.grab_hatch() + @override def is_finished(self) -> bool: return True diff --git a/examples/robot/HatchbotTraditional/commands/halvedrivevelocity.py b/examples/robot/HatchbotTraditional/commands/halvedrivevelocity.py index 5b2fd73fa..a6d6959b0 100644 --- a/examples/robot/HatchbotTraditional/commands/halvedrivevelocity.py +++ b/examples/robot/HatchbotTraditional/commands/halvedrivevelocity.py @@ -4,6 +4,8 @@ # the WPILib BSD license file in the root directory of this project. # +from typing import override + import commands2 from subsystems.drivesubsystem import DriveSubsystem @@ -13,8 +15,10 @@ class HalveDriveVelocity(commands2.Command): def __init__(self, drive: DriveSubsystem) -> None: self.drive = drive + @override def initialize(self) -> None: self.drive.set_max_output(0.5) + @override def end(self, interrupted: bool) -> None: self.drive.set_max_output(1.0) diff --git a/examples/robot/HatchbotTraditional/robot.py b/examples/robot/HatchbotTraditional/robot.py index c2980efb0..8d2d15f37 100644 --- a/examples/robot/HatchbotTraditional/robot.py +++ b/examples/robot/HatchbotTraditional/robot.py @@ -5,7 +5,7 @@ # the WPILib BSD license file in the root directory of this project. # -import typing +from typing import override import commands2 import wpilib @@ -19,7 +19,7 @@ class MyRobot(commands2.TimedCommandRobot): has an implementation of robot_periodic which runs the scheduler for you """ - autonomous_command: typing.Optional[commands2.Command] = None + autonomous_command: commands2.Command | None = None def __init__(self) -> None: """ @@ -39,16 +39,20 @@ def __init__(self) -> None: # Change to `false` to not record joystick data. wpilib.DriverStation.start_data_log(wpilib.DataLogManager.get_log(), True) + @override def robot_periodic(self) -> None: super().robot_periodic() self.container.update_telemetry() + @override def disabled_init(self) -> None: """This function is called once each time the robot enters Disabled mode.""" + @override def disabled_periodic(self) -> None: """This function is called periodically when disabled""" + @override def autonomous_init(self) -> None: """This autonomous runs the autonomous command selected by your RobotContainer class.""" self.autonomous_command = self.container.get_autonomous_command() @@ -56,9 +60,11 @@ def autonomous_init(self) -> None: if self.autonomous_command: self.autonomous_command.schedule() + @override def autonomous_periodic(self) -> None: """This function is called periodically during autonomous""" + @override def teleop_init(self) -> None: # This makes sure that the autonomous stops running when # teleop starts running. If you want the autonomous to @@ -67,9 +73,11 @@ def teleop_init(self) -> None: if self.autonomous_command: self.autonomous_command.cancel() + @override def teleop_periodic(self) -> None: """This function is called periodically during operator control""" + @override def utility_init(self) -> None: # Cancels all running commands at the start of utility mode commands2.CommandScheduler.get_instance().cancel_all() diff --git a/examples/robot/HatchbotTraditional/subsystems/drivesubsystem.py b/examples/robot/HatchbotTraditional/subsystems/drivesubsystem.py index 5423aa15e..d5852d810 100644 --- a/examples/robot/HatchbotTraditional/subsystems/drivesubsystem.py +++ b/examples/robot/HatchbotTraditional/subsystems/drivesubsystem.py @@ -4,6 +4,8 @@ # the WPILib BSD license file in the root directory of this project. # +from typing import override + import commands2 import telemetry import wpilib @@ -67,6 +69,7 @@ def set_max_output(self, max_output: float): """ self.drive.set_max_output(max_output) + @override def log_to(self, table: telemetry.TelemetryTable) -> None: super().log_to(table) table.log("leftDistance", self.left_encoder.get_distance()) diff --git a/examples/robot/HatchbotTraditional/subsystems/hatchsubsystem.py b/examples/robot/HatchbotTraditional/subsystems/hatchsubsystem.py index 02861e34d..20eb628ea 100644 --- a/examples/robot/HatchbotTraditional/subsystems/hatchsubsystem.py +++ b/examples/robot/HatchbotTraditional/subsystems/hatchsubsystem.py @@ -4,6 +4,8 @@ # the WPILib BSD license file in the root directory of this project. # +from typing import override + import telemetry import wpilib import commands2 @@ -28,6 +30,7 @@ def release_hatch(self) -> None: """Releases the hatch""" self.hatch_solenoid.set(wpilib.DoubleSolenoid.Value.REVERSE) + @override def log_to(self, table: telemetry.TelemetryTable) -> None: super().log_to(table) table.log( diff --git a/examples/robot/MecanumBot/robot.py b/examples/robot/MecanumBot/robot.py index a120f44f4..4242a1a99 100755 --- a/examples/robot/MecanumBot/robot.py +++ b/examples/robot/MecanumBot/robot.py @@ -5,6 +5,8 @@ # the WPILib BSD license file in the root directory of this project. # +from typing import override + import wpimath import wpilib @@ -23,10 +25,12 @@ def __init__(self) -> None: self.y_velocity_limiter = wpimath.SlewRateLimiter(3) self.rot_limiter = wpimath.SlewRateLimiter(3) + @override def autonomous_periodic(self) -> None: self.drive_with_joystick(False) self.mecanum.update_odometry() + @override def teleop_periodic(self) -> None: self.drive_with_joystick(True) diff --git a/examples/robot/MecanumDrive/robot.py b/examples/robot/MecanumDrive/robot.py index 6bbc2112e..ff6020882 100755 --- a/examples/robot/MecanumDrive/robot.py +++ b/examples/robot/MecanumDrive/robot.py @@ -6,6 +6,8 @@ # +from typing import override + import wpilib import wpilib_drivers @@ -42,6 +44,7 @@ def __init__(self) -> None: front_left, rear_left, front_right, rear_right ) + @override def teleop_periodic(self) -> None: self.robot_drive.drive_cartesian( -self.joystick.get_y(), diff --git a/examples/robot/MecanumDrivePoseEstimator/robot.py b/examples/robot/MecanumDrivePoseEstimator/robot.py index 247694001..3f2de1636 100644 --- a/examples/robot/MecanumDrivePoseEstimator/robot.py +++ b/examples/robot/MecanumDrivePoseEstimator/robot.py @@ -5,6 +5,8 @@ # the WPILib BSD license file in the root directory of this project. # +from typing import override + import wpilib import wpimath @@ -23,10 +25,12 @@ def __init__(self) -> None: self.y_velocity_limiter = wpimath.SlewRateLimiter(3) self.rot_limiter = wpimath.SlewRateLimiter(3) + @override def autonomous_periodic(self) -> None: self.drive_with_joystick(False) self.mecanum.update_odometry() + @override def teleop_periodic(self) -> None: self.drive_with_joystick(True) diff --git a/examples/robot/Mechanism2d/robot.py b/examples/robot/Mechanism2d/robot.py index d13512b25..5c653f666 100755 --- a/examples/robot/Mechanism2d/robot.py +++ b/examples/robot/Mechanism2d/robot.py @@ -5,6 +5,8 @@ # the WPILib BSD license file in the root directory of this project. # +from typing import override + import telemetry import wpilib import wpilib_drivers @@ -47,6 +49,7 @@ def __init__(self): "wrist", 0.5, 90, 6, wpiutil.Color8Bit(wpiutil.Color.PURPLE) ) + @override def robot_periodic(self): # update the dashboard mechanism's state self.elevator.set_length( @@ -57,6 +60,7 @@ def robot_periodic(self): # post the mechanism to the dashboard telemetry.log("Mech2d", self.mech) + @override def teleop_periodic(self): self.elevator_motor.set_throttle(self.joystick.get_raw_axis(0)) self.wrist_motor.set_throttle(self.joystick.get_raw_axis(1)) diff --git a/examples/robot/RapidReactCommandBot/rapidreactcommandbot.py b/examples/robot/RapidReactCommandBot/rapidreactcommandbot.py index ef410fa9e..2bccc9fa0 100644 --- a/examples/robot/RapidReactCommandBot/rapidreactcommandbot.py +++ b/examples/robot/RapidReactCommandBot/rapidreactcommandbot.py @@ -5,7 +5,7 @@ # import commands2 -from commands2.button import CommandXboxController, Trigger +from commands2.button import CommandXboxController from constants import AutoConstants, OIConstants, ShooterConstants from subsystems.drive import Drive diff --git a/examples/robot/RapidReactCommandBot/robot.py b/examples/robot/RapidReactCommandBot/robot.py index 569ad6a86..3b95e4194 100644 --- a/examples/robot/RapidReactCommandBot/robot.py +++ b/examples/robot/RapidReactCommandBot/robot.py @@ -5,6 +5,8 @@ # the WPILib BSD license file in the root directory of this project. # +from typing import override + import commands2 import wpilib @@ -32,23 +34,28 @@ def __init__(self) -> None: # Initialize data logging. wpilib.DataLogManager.start() + @override def disabled_init(self) -> None: """This function is called once each time the robot enters Disabled mode.""" pass + @override def disabled_periodic(self) -> None: pass + @override def autonomous_init(self) -> None: self.autonomous_command = self.robot.get_autonomous_command() if self.autonomous_command is not None: self.autonomous_command.schedule() + @override def autonomous_periodic(self) -> None: """This function is called periodically during autonomous.""" pass + @override def teleop_init(self) -> None: # This makes sure that the autonomous stops running when # teleop starts running. If you want the autonomous to @@ -57,14 +64,17 @@ def teleop_init(self) -> None: if self.autonomous_command is not None: self.autonomous_command.cancel() + @override def teleop_periodic(self) -> None: """This function is called periodically during operator control.""" pass + @override def utility_init(self) -> None: # Cancels all running commands at the start of utility mode. commands2.CommandScheduler.get_instance().cancel_all() + @override def utility_periodic(self) -> None: """This function is called periodically during utility mode.""" pass diff --git a/examples/robot/RapidReactCommandBot/subsystems/drive.py b/examples/robot/RapidReactCommandBot/subsystems/drive.py index 5d21dcd5f..0c57474c2 100644 --- a/examples/robot/RapidReactCommandBot/subsystems/drive.py +++ b/examples/robot/RapidReactCommandBot/subsystems/drive.py @@ -4,7 +4,7 @@ # the WPILib BSD license file in the root directory of this project. # -from typing import Callable +from collections.abc import Callable from commands2 import Command, Subsystem import wpilib diff --git a/examples/robot/RomiReference/commands/arcadedrive.py b/examples/robot/RomiReference/commands/arcadedrive.py index 283673eda..2a2755927 100644 --- a/examples/robot/RomiReference/commands/arcadedrive.py +++ b/examples/robot/RomiReference/commands/arcadedrive.py @@ -5,6 +5,8 @@ # import typing +from typing import override + import commands2 from subsystems.drivetrain import Drivetrain @@ -30,5 +32,6 @@ def __init__( self.add_requirements(self.drive) + @override def execute(self) -> None: self.drive.arcade_drive(self.forward(), self.rotation()) diff --git a/examples/robot/RomiReference/commands/drivedistance.py b/examples/robot/RomiReference/commands/drivedistance.py index 97cbaa219..5d51facef 100644 --- a/examples/robot/RomiReference/commands/drivedistance.py +++ b/examples/robot/RomiReference/commands/drivedistance.py @@ -4,6 +4,8 @@ # the WPILib BSD license file in the root directory of this project. # +from typing import override + import commands2 from subsystems.drivetrain import Drivetrain @@ -24,19 +26,23 @@ def __init__(self, velocity: float, inches: float, drive: Drivetrain) -> None: self.drive = drive self.add_requirements(drive) + @override def initialize(self) -> None: """Called when the command is initially scheduled.""" self.drive.arcade_drive(0, 0) self.drive.reset_encoders() + @override def execute(self) -> None: """Called every time the scheduler runs while the command is scheduled.""" self.drive.arcade_drive(self.velocity, 0) + @override def end(self, interrupted: bool) -> None: """Called once the command ends or is interrupted.""" self.drive.arcade_drive(0, 0) + @override def is_finished(self) -> bool: """Returns true when the command should end.""" # Compare distance travelled from start to desired distance diff --git a/examples/robot/RomiReference/commands/drivetime.py b/examples/robot/RomiReference/commands/drivetime.py index 5f0ca9d11..09437ba0a 100644 --- a/examples/robot/RomiReference/commands/drivetime.py +++ b/examples/robot/RomiReference/commands/drivetime.py @@ -4,6 +4,8 @@ # the WPILib BSD license file in the root directory of this project. # +from typing import override + import commands2 import wpilib @@ -28,19 +30,23 @@ def __init__(self, velocity: float, time: float, drive: Drivetrain) -> None: self.start_time = 0.0 + @override def initialize(self) -> None: """Called when the command is initially scheduled.""" self.start_time = wpilib.Timer.get_timestamp() self.drive.arcade_drive(0, 0) + @override def execute(self) -> None: """Called every time the scheduler runs while the command is scheduled.""" self.drive.arcade_drive(self.velocity, 0) + @override def end(self, interrupted: bool) -> None: """Called once the command ends or is interrupted.""" self.drive.arcade_drive(0, 0) + @override def is_finished(self) -> bool: """Returns true when the command should end""" return wpilib.Timer.get_timestamp() - self.start_time >= self.duration diff --git a/examples/robot/RomiReference/commands/turndegrees.py b/examples/robot/RomiReference/commands/turndegrees.py index 74a25fab9..bfdc6849d 100644 --- a/examples/robot/RomiReference/commands/turndegrees.py +++ b/examples/robot/RomiReference/commands/turndegrees.py @@ -4,6 +4,8 @@ # the WPILib BSD license file in the root directory of this project. # +from typing import override + import math import commands2 @@ -25,20 +27,24 @@ def __init__(self, velocity: float, degrees: float, drive: Drivetrain) -> None: self.drive = drive self.add_requirements(drive) + @override def initialize(self) -> None: """Called when the command is initially scheduled.""" # Set motors to stop, read encoder values for starting point self.drive.arcade_drive(0, 0) self.drive.reset_encoders() + @override def execute(self) -> None: """Called every time the scheduler runs while the command is scheduled.""" self.drive.arcade_drive(0, self.velocity) + @override def end(self, interrupted: bool) -> None: """Called once the command ends or is interrupted.""" self.drive.arcade_drive(0, 0) + @override def is_finished(self) -> bool: """Returns true when the command should end.""" diff --git a/examples/robot/RomiReference/commands/turntime.py b/examples/robot/RomiReference/commands/turntime.py index 33e59832c..33750477c 100644 --- a/examples/robot/RomiReference/commands/turntime.py +++ b/examples/robot/RomiReference/commands/turntime.py @@ -4,6 +4,8 @@ # the WPILib BSD license file in the root directory of this project. # +from typing import override + import commands2 import wpilib @@ -30,19 +32,23 @@ def __init__(self, velocity: float, time: float, drive: Drivetrain) -> None: self.start_time = 0.0 + @override def initialize(self) -> None: """Called when the command is initially scheduled.""" self.start_time = wpilib.Timer.get_timestamp() self.drive.arcade_drive(0, 0) + @override def execute(self) -> None: """Called every time the scheduler runs while the command is scheduled.""" self.drive.arcade_drive(0, self.rotational_velocity) + @override def end(self, interrupted: bool) -> None: """Called once the command ends or is interrupted.""" self.drive.arcade_drive(0, 0) + @override def is_finished(self) -> bool: """Returns true when the command should end""" return wpilib.Timer.get_timestamp() - self.start_time >= self.duration diff --git a/examples/robot/RomiReference/robot.py b/examples/robot/RomiReference/robot.py index 3b633ea37..f262b4f0c 100644 --- a/examples/robot/RomiReference/robot.py +++ b/examples/robot/RomiReference/robot.py @@ -38,10 +38,9 @@ # you can add the --nogui option. # -import typing +from typing import override import telemetry -import wpilib import commands2 from robotcontainer import RobotContainer @@ -53,7 +52,7 @@ class MyRobot(commands2.TimedCommandRobot): has an implementation of robot_periodic which runs the scheduler for you """ - autonomous_command: typing.Optional[commands2.Command] = None + autonomous_command: commands2.Command | None = None def __init__(self) -> None: """ @@ -66,16 +65,20 @@ def __init__(self) -> None: # autonomous chooser on the dashboard. self.container = RobotContainer() + @override def robot_periodic(self) -> None: super().robot_periodic() telemetry.log("", self.container) + @override def disabled_init(self) -> None: """This function is called once each time the robot enters Disabled mode.""" + @override def disabled_periodic(self) -> None: """This function is called periodically when disabled""" + @override def autonomous_init(self) -> None: """This autonomous runs the autonomous command selected by your RobotContainer class.""" self.autonomous_command = self.container.get_autonomous_command() @@ -83,9 +86,11 @@ def autonomous_init(self) -> None: if self.autonomous_command: self.autonomous_command.schedule() + @override def autonomous_periodic(self) -> None: """This function is called periodically during autonomous""" + @override def teleop_init(self) -> None: # This makes sure that the autonomous stops running when # teleop starts running. If you want the autonomous to @@ -94,9 +99,11 @@ def teleop_init(self) -> None: if self.autonomous_command: self.autonomous_command.cancel() + @override def teleop_periodic(self) -> None: """This function is called periodically during operator control""" + @override def utility_init(self) -> None: # Cancels all running commands at the start of utility mode commands2.CommandScheduler.get_instance().cancel_all() diff --git a/examples/robot/RomiReference/robotcontainer.py b/examples/robot/RomiReference/robotcontainer.py index 049f4f405..104e5d490 100644 --- a/examples/robot/RomiReference/robotcontainer.py +++ b/examples/robot/RomiReference/robotcontainer.py @@ -4,8 +4,6 @@ # the WPILib BSD license file in the root directory of this project. # -import typing - import commands2 import commands2.button import telemetry @@ -79,7 +77,7 @@ def _configure_button_bindings(self): self.chooser.add("Auto Routine Time", AutonomousTime(self.drivetrain)) tunables.publish("Autonomous", self.chooser) - def get_autonomous_command(self) -> typing.Optional[commands2.Command]: + def get_autonomous_command(self) -> commands2.Command | None: return self.chooser.get_selected() def get_arcade_drive_command(self) -> ArcadeDrive: diff --git a/examples/robot/RomiReference/subsystems/drivetrain.py b/examples/robot/RomiReference/subsystems/drivetrain.py index 1ddfce4d7..0752a3172 100644 --- a/examples/robot/RomiReference/subsystems/drivetrain.py +++ b/examples/robot/RomiReference/subsystems/drivetrain.py @@ -5,12 +5,13 @@ # import math +from typing import override import commands2 +import romi import telemetry import wpilib import wpilib_drivers -import romi class Drivetrain(commands2.Subsystem): @@ -103,6 +104,7 @@ def reset_gyro(self) -> None: """Reset the gyro""" self.gyro.reset() + @override def log_to(self, table: telemetry.TelemetryTable) -> None: super().log_to(table) table.log("drive", self.drive) diff --git a/examples/robot/SimpleDifferentialDriveSimulation/robot.py b/examples/robot/SimpleDifferentialDriveSimulation/robot.py index c8eabb0f6..668a42eb1 100644 --- a/examples/robot/SimpleDifferentialDriveSimulation/robot.py +++ b/examples/robot/SimpleDifferentialDriveSimulation/robot.py @@ -5,6 +5,8 @@ # the WPILib BSD license file in the root directory of this project. # +from typing import override + import wpilib import wpimath @@ -33,19 +35,23 @@ def __init__(self) -> None: wpimath.TrajectoryConfig(2, 2), ) + @override def robot_periodic(self) -> None: self.drive.periodic() + @override def autonomous_init(self) -> None: self.timer.restart() self.drive.reset_odometry(self.trajectory.initial_pose()) + @override def autonomous_periodic(self) -> None: elapsed = self.timer.get() reference = self.trajectory.sample_at(elapsed) velocities = self.feedback.calculate(self.drive.get_pose(), reference) self.drive.drive(velocities.vx, velocities.omega) + @override def teleop_periodic(self) -> None: # Get the x velocity. We are inverting this because Xbox controllers return # negative values when we push forward. @@ -64,5 +70,6 @@ def teleop_periodic(self) -> None: ) self.drive.drive(x_velocity, rot) + @override def simulation_periodic(self) -> None: self.drive.simulation_periodic() diff --git a/examples/robot/StateSpaceArm/robot.py b/examples/robot/StateSpaceArm/robot.py index 9cc154b32..47bf2394a 100644 --- a/examples/robot/StateSpaceArm/robot.py +++ b/examples/robot/StateSpaceArm/robot.py @@ -6,10 +6,12 @@ # import math +from typing import override + import wpilib import wpilib_drivers -import wpimath.units import wpimath +import wpimath.units MOTOR_PORT = 0 ENCODER_A_CHANNEL = 0 @@ -104,6 +106,7 @@ def __init__(self) -> None: # We go 2 pi radians in 1 rotation, or 4096 counts. self.encoder.set_distance_per_pulse(math.tau / 4096) + @override def teleop_init(self) -> None: # Reset our loop to make sure it's in a known state. self.loop.reset([self.encoder.get_distance(), self.encoder.get_rate()]) @@ -113,6 +116,7 @@ def teleop_init(self) -> None: self.encoder.get_distance(), self.encoder.get_rate() ) + @override def teleop_periodic(self) -> None: # Sets the target position of our arm. This is similar to setting the setpoint of a # PID controller. diff --git a/examples/robot/StateSpaceElevator/robot.py b/examples/robot/StateSpaceElevator/robot.py index 44c945935..da815ade0 100644 --- a/examples/robot/StateSpaceElevator/robot.py +++ b/examples/robot/StateSpaceElevator/robot.py @@ -6,6 +6,8 @@ # import math +from typing import override + import wpilib import wpilib_drivers import wpimath @@ -111,6 +113,7 @@ def __init__(self) -> None: # Circumference = pi * d, so distance per click = pi * d / counts self.encoder.set_distance_per_pulse(math.tau * DRUM_RADIUS / 4096) + @override def teleop_init(self) -> None: # Reset our loop to make sure it's in a known state. self.loop.reset([self.encoder.get_distance(), self.encoder.get_rate()]) @@ -120,6 +123,7 @@ def teleop_init(self) -> None: self.encoder.get_distance(), self.encoder.get_rate() ) + @override def teleop_periodic(self) -> None: # Sets the target position of our arm. This is similar to setting the setpoint of a # PID controller. diff --git a/examples/robot/StateSpaceFlywheel/robot.py b/examples/robot/StateSpaceFlywheel/robot.py index 80b055680..d895f8619 100644 --- a/examples/robot/StateSpaceFlywheel/robot.py +++ b/examples/robot/StateSpaceFlywheel/robot.py @@ -6,6 +6,7 @@ # import math +from typing import override import wpilib import wpilib_drivers @@ -87,9 +88,11 @@ def __init__(self) -> None: # We go 2 pi radians per 4096 clicks. self.encoder.set_distance_per_pulse(math.tau / 4096) + @override def teleop_init(self) -> None: self.loop.reset([self.encoder.get_rate()]) + @override def teleop_periodic(self) -> None: # Sets the target velocity of our flywheel. This is similar to setting the setpoint of a # PID controller. diff --git a/examples/robot/StateSpaceFlywheelSysId/robot.py b/examples/robot/StateSpaceFlywheelSysId/robot.py index 93d4ba072..8263cd670 100644 --- a/examples/robot/StateSpaceFlywheelSysId/robot.py +++ b/examples/robot/StateSpaceFlywheelSysId/robot.py @@ -6,6 +6,8 @@ # import math +from typing import override + import wpilib import wpilib_drivers import wpimath @@ -76,9 +78,11 @@ def __init__(self) -> None: # We go 2 pi radians per 4096 clicks. self.encoder.set_distance_per_pulse(math.tau / 4096) + @override def teleop_init(self) -> None: self.loop.reset([self.encoder.get_rate()]) + @override def teleop_periodic(self) -> None: # Sets the target velocity of our flywheel. This is similar to setting the setpoint of a # PID controller. diff --git a/examples/robot/SwerveBot/robot.py b/examples/robot/SwerveBot/robot.py index 21f3e7a7d..46da6cee3 100644 --- a/examples/robot/SwerveBot/robot.py +++ b/examples/robot/SwerveBot/robot.py @@ -5,6 +5,8 @@ # the WPILib BSD license file in the root directory of this project. # +from typing import override + import wpilib import wpimath import drivetrain @@ -22,10 +24,12 @@ def __init__(self) -> None: self.y_velocity_limiter = wpimath.SlewRateLimiter(3) self.rot_limiter = wpimath.SlewRateLimiter(3) + @override def autonomous_periodic(self) -> None: self.drive_with_joystick(False) self.swerve.update_odometry() + @override def teleop_periodic(self) -> None: self.drive_with_joystick(True) diff --git a/examples/robot/SwerveDrivePoseEstimator/robot.py b/examples/robot/SwerveDrivePoseEstimator/robot.py index 8575575d4..ea8cf4e71 100644 --- a/examples/robot/SwerveDrivePoseEstimator/robot.py +++ b/examples/robot/SwerveDrivePoseEstimator/robot.py @@ -5,6 +5,8 @@ # the WPILib BSD license file in the root directory of this project. # +from typing import override + import wpilib import wpimath @@ -23,10 +25,12 @@ def __init__(self) -> None: self.y_velocity_limiter = wpimath.SlewRateLimiter(3) self.rot_limiter = wpimath.SlewRateLimiter(3) + @override def autonomous_periodic(self) -> None: self.drive_with_joystick(False) self.swerve.update_odometry() + @override def teleop_periodic(self) -> None: self.drive_with_joystick(True) diff --git a/examples/robot/SysId/robot.py b/examples/robot/SysId/robot.py index d89e94ee9..a2c1bd92b 100644 --- a/examples/robot/SysId/robot.py +++ b/examples/robot/SysId/robot.py @@ -5,6 +5,8 @@ # the WPILib BSD license file in the root directory of this project. # +from typing import override + from commands2 import CommandScheduler, TimedCommandRobot from sysidroutinebot import SysIdRoutineBot @@ -28,23 +30,28 @@ def __init__(self) -> None: self.autonomous_command = None + @override def disabled_init(self) -> None: """This function is called once each time the robot enters Disabled mode.""" pass + @override def disabled_periodic(self) -> None: pass + @override def autonomous_init(self) -> None: self.autonomous_command = self.robot.get_autonomous_command() if self.autonomous_command is not None: CommandScheduler.get_instance().schedule(self.autonomous_command) + @override def autonomous_periodic(self) -> None: """This function is called periodically during autonomous.""" pass + @override def teleop_init(self) -> None: # This makes sure that the autonomous stops running when # teleop starts running. If you want the autonomous to @@ -53,14 +60,17 @@ def teleop_init(self) -> None: if self.autonomous_command is not None: self.autonomous_command.cancel() + @override def teleop_periodic(self) -> None: """This function is called periodically during operator control.""" pass + @override def utility_init(self) -> None: # Cancels all running commands at the start of utility mode. CommandScheduler.get_instance().cancel_all() + @override def utility_periodic(self) -> None: """This function is called periodically during utility mode.""" pass diff --git a/examples/robot/SysId/subsystems/drive.py b/examples/robot/SysId/subsystems/drive.py index 5e41e4dc8..b040879d5 100644 --- a/examples/robot/SysId/subsystems/drive.py +++ b/examples/robot/SysId/subsystems/drive.py @@ -4,7 +4,7 @@ # the WPILib BSD license file in the root directory of this project. # -from typing import Callable +from collections.abc import Callable from commands2 import Command, Subsystem from commands2.sysid import SysIdRoutine diff --git a/examples/robot/SysId/subsystems/shooter.py b/examples/robot/SysId/subsystems/shooter.py index 5e13fa736..db212abe8 100644 --- a/examples/robot/SysId/subsystems/shooter.py +++ b/examples/robot/SysId/subsystems/shooter.py @@ -4,7 +4,7 @@ # the WPILib BSD license file in the root directory of this project. # -from typing import Callable +from collections.abc import Callable from commands2 import Command, Subsystem from commands2.sysid import SysIdRoutine diff --git a/examples/robot/TankDrive/robot.py b/examples/robot/TankDrive/robot.py index d18e31d8e..2c7839f65 100755 --- a/examples/robot/TankDrive/robot.py +++ b/examples/robot/TankDrive/robot.py @@ -5,6 +5,8 @@ # the WPILib BSD license file in the root directory of this project. # +from typing import override + import wpilib import wpilib_drivers @@ -30,5 +32,6 @@ def __init__(self): # gearbox is constructed, you might have to invert the left side instead. right_motor.set_inverted(True) + @override def teleop_periodic(self): self.robot_drive.tank_drive(-self.left_stick.get_y(), -self.right_stick.get_y()) diff --git a/examples/robot/TankDriveXboxController/robot.py b/examples/robot/TankDriveXboxController/robot.py index 0a99d1c7b..b1718c4ef 100755 --- a/examples/robot/TankDriveXboxController/robot.py +++ b/examples/robot/TankDriveXboxController/robot.py @@ -5,6 +5,8 @@ # the WPILib BSD license file in the root directory of this project. # +from typing import override + import wpilib import wpilib_drivers @@ -29,6 +31,7 @@ def __init__(self): # gearbox is constructed, you might have to invert the left side instead. right_motor.set_inverted(True) + @override def teleop_periodic(self): # Drive with tank drive. # That means that the Y axis of the left stick moves the left side diff --git a/examples/robot/UnitTest/robot.py b/examples/robot/UnitTest/robot.py index 3ab7a8f94..a65a07e8d 100644 --- a/examples/robot/UnitTest/robot.py +++ b/examples/robot/UnitTest/robot.py @@ -5,6 +5,8 @@ # the WPILib BSD license file in the root directory of this project. # +from typing import override + import wpilib import constants @@ -23,6 +25,7 @@ def __init__(self) -> None: self.intake = Intake() self.joystick = wpilib.Joystick(constants.JOYSTICK_INDEX) + @override def teleop_periodic(self) -> None: """This function is called periodically during operator control.""" # Activate the intake while the trigger is held diff --git a/examples/robot/XrpReference/commands/arcadedrive.py b/examples/robot/XrpReference/commands/arcadedrive.py index 09ae98af1..2f99e5b22 100644 --- a/examples/robot/XrpReference/commands/arcadedrive.py +++ b/examples/robot/XrpReference/commands/arcadedrive.py @@ -5,6 +5,8 @@ # import typing +from typing import override + import commands2 from subsystems.drivetrain import Drivetrain @@ -30,6 +32,7 @@ def __init__( self.add_requirements(self.drive) + @override def execute(self) -> None: self.drive.arcade_drive( self.x_axis_velocity_supplier(), self.z_axis_rotate_supplier() diff --git a/examples/robot/XrpReference/commands/drivedistance.py b/examples/robot/XrpReference/commands/drivedistance.py index 97cbaa219..5d51facef 100644 --- a/examples/robot/XrpReference/commands/drivedistance.py +++ b/examples/robot/XrpReference/commands/drivedistance.py @@ -4,6 +4,8 @@ # the WPILib BSD license file in the root directory of this project. # +from typing import override + import commands2 from subsystems.drivetrain import Drivetrain @@ -24,19 +26,23 @@ def __init__(self, velocity: float, inches: float, drive: Drivetrain) -> None: self.drive = drive self.add_requirements(drive) + @override def initialize(self) -> None: """Called when the command is initially scheduled.""" self.drive.arcade_drive(0, 0) self.drive.reset_encoders() + @override def execute(self) -> None: """Called every time the scheduler runs while the command is scheduled.""" self.drive.arcade_drive(self.velocity, 0) + @override def end(self, interrupted: bool) -> None: """Called once the command ends or is interrupted.""" self.drive.arcade_drive(0, 0) + @override def is_finished(self) -> bool: """Returns true when the command should end.""" # Compare distance travelled from start to desired distance diff --git a/examples/robot/XrpReference/commands/drivetime.py b/examples/robot/XrpReference/commands/drivetime.py index 5f0ca9d11..09437ba0a 100644 --- a/examples/robot/XrpReference/commands/drivetime.py +++ b/examples/robot/XrpReference/commands/drivetime.py @@ -4,6 +4,8 @@ # the WPILib BSD license file in the root directory of this project. # +from typing import override + import commands2 import wpilib @@ -28,19 +30,23 @@ def __init__(self, velocity: float, time: float, drive: Drivetrain) -> None: self.start_time = 0.0 + @override def initialize(self) -> None: """Called when the command is initially scheduled.""" self.start_time = wpilib.Timer.get_timestamp() self.drive.arcade_drive(0, 0) + @override def execute(self) -> None: """Called every time the scheduler runs while the command is scheduled.""" self.drive.arcade_drive(self.velocity, 0) + @override def end(self, interrupted: bool) -> None: """Called once the command ends or is interrupted.""" self.drive.arcade_drive(0, 0) + @override def is_finished(self) -> bool: """Returns true when the command should end""" return wpilib.Timer.get_timestamp() - self.start_time >= self.duration diff --git a/examples/robot/XrpReference/commands/turndegrees.py b/examples/robot/XrpReference/commands/turndegrees.py index 0772aed85..d2f56bb88 100644 --- a/examples/robot/XrpReference/commands/turndegrees.py +++ b/examples/robot/XrpReference/commands/turndegrees.py @@ -5,6 +5,8 @@ # import math +from typing import override + import commands2 from subsystems.drivetrain import Drivetrain @@ -25,20 +27,24 @@ def __init__(self, velocity: float, degrees: float, drive: Drivetrain) -> None: self.drive = drive self.add_requirements(drive) + @override def initialize(self) -> None: """Called when the command is initially scheduled.""" # Set motors to stop, read encoder values for starting point self.drive.arcade_drive(0, 0) self.drive.reset_encoders() + @override def execute(self) -> None: """Called every time the scheduler runs while the command is scheduled.""" self.drive.arcade_drive(0, self.velocity) + @override def end(self, interrupted: bool) -> None: """Called once the command ends or is interrupted.""" self.drive.arcade_drive(0, 0) + @override def is_finished(self) -> bool: """Returns true when the command should end.""" diff --git a/examples/robot/XrpReference/commands/turntime.py b/examples/robot/XrpReference/commands/turntime.py index 33e59832c..33750477c 100644 --- a/examples/robot/XrpReference/commands/turntime.py +++ b/examples/robot/XrpReference/commands/turntime.py @@ -4,6 +4,8 @@ # the WPILib BSD license file in the root directory of this project. # +from typing import override + import commands2 import wpilib @@ -30,19 +32,23 @@ def __init__(self, velocity: float, time: float, drive: Drivetrain) -> None: self.start_time = 0.0 + @override def initialize(self) -> None: """Called when the command is initially scheduled.""" self.start_time = wpilib.Timer.get_timestamp() self.drive.arcade_drive(0, 0) + @override def execute(self) -> None: """Called every time the scheduler runs while the command is scheduled.""" self.drive.arcade_drive(0, self.rotational_velocity) + @override def end(self, interrupted: bool) -> None: """Called once the command ends or is interrupted.""" self.drive.arcade_drive(0, 0) + @override def is_finished(self) -> bool: """Returns true when the command should end""" return wpilib.Timer.get_timestamp() - self.start_time >= self.duration diff --git a/examples/robot/XrpReference/robot.py b/examples/robot/XrpReference/robot.py index 0fb118d19..2dc87b07a 100644 --- a/examples/robot/XrpReference/robot.py +++ b/examples/robot/XrpReference/robot.py @@ -38,9 +38,8 @@ # you can add the --nogui option. # -import typing +from typing import override -import wpilib import commands2 from robotcontainer import RobotContainer @@ -52,7 +51,7 @@ class MyRobot(commands2.TimedCommandRobot): has an implementation of robot_periodic which runs the scheduler for you """ - autonomous_command: typing.Optional[commands2.Command] = None + autonomous_command: commands2.Command | None = None def __init__(self) -> None: """ @@ -65,12 +64,15 @@ def __init__(self) -> None: # autonomous chooser on the dashboard. self.container = RobotContainer() + @override def disabled_init(self) -> None: """This function is called once each time the robot enters Disabled mode.""" + @override def disabled_periodic(self) -> None: """This function is called periodically when disabled""" + @override def autonomous_init(self) -> None: """This autonomous runs the autonomous command selected by your RobotContainer class.""" self.autonomous_command = self.container.get_autonomous_command() @@ -78,9 +80,11 @@ def autonomous_init(self) -> None: if self.autonomous_command: self.autonomous_command.schedule() + @override def autonomous_periodic(self) -> None: """This function is called periodically during autonomous""" + @override def teleop_init(self) -> None: # This makes sure that the autonomous stops running when # teleop starts running. If you want the autonomous to @@ -89,9 +93,11 @@ def teleop_init(self) -> None: if self.autonomous_command: self.autonomous_command.cancel() + @override def teleop_periodic(self) -> None: """This function is called periodically during operator control""" + @override def utility_init(self) -> None: # Cancels all running commands at the start of utility mode commands2.CommandScheduler.get_instance().cancel_all() diff --git a/examples/robot/XrpReference/robotcontainer.py b/examples/robot/XrpReference/robotcontainer.py index e693826a2..eb6ed01b4 100644 --- a/examples/robot/XrpReference/robotcontainer.py +++ b/examples/robot/XrpReference/robotcontainer.py @@ -4,8 +4,6 @@ # the WPILib BSD license file in the root directory of this project. # -import typing - import commands2 import commands2.button import tunables @@ -83,7 +81,7 @@ def _configure_button_bindings(self): self.chooser.add("Auto Routine Time", AutonomousTime(self.drivetrain)) tunables.publish("Autonomous", self.chooser) - def get_autonomous_command(self) -> typing.Optional[commands2.Command]: + def get_autonomous_command(self) -> commands2.Command | None: return self.chooser.get_selected() def get_arcade_drive_command(self) -> ArcadeDrive: diff --git a/examples/robot/XrpReference/subsystems/arm.py b/examples/robot/XrpReference/subsystems/arm.py index 612c54f5f..3661a7811 100644 --- a/examples/robot/XrpReference/subsystems/arm.py +++ b/examples/robot/XrpReference/subsystems/arm.py @@ -4,6 +4,8 @@ # the WPILib BSD license file in the root directory of this project. # +from typing import override + import commands2 import xrp @@ -16,6 +18,7 @@ def __init__(self): # Device number 4 maps to the physical Servo 1 port on the XRP self.arm_servo = xrp.XRPServo(4) + @override def periodic(self): """This method will be called once per scheduler run""" diff --git a/examples/robot/XrpReference/subsystems/drivetrain.py b/examples/robot/XrpReference/subsystems/drivetrain.py index fc6cb8609..e75685cd7 100644 --- a/examples/robot/XrpReference/subsystems/drivetrain.py +++ b/examples/robot/XrpReference/subsystems/drivetrain.py @@ -5,10 +5,10 @@ # import math +from typing import override import commands2 import wpilib -import wpiutil import xrp @@ -107,5 +107,6 @@ def reset_gyro(self) -> None: """Reset the gyro""" self.gyro.reset() + @override def periodic(self) -> None: """This method will be called once per scheduler run""" diff --git a/snippets/robot/AddressableLED/robot.py b/snippets/robot/AddressableLED/robot.py index 309a30350..30e592b7e 100644 --- a/snippets/robot/AddressableLED/robot.py +++ b/snippets/robot/AddressableLED/robot.py @@ -5,6 +5,8 @@ # the WPILib BSD license file in the root directory of this project. # +from typing import override + import wpilib @@ -37,6 +39,7 @@ def __init__(self) -> None: self.LED_SPACING, ) + @override def robot_periodic(self) -> None: # Update the buffer with the rainbow animation self.scrolling_rainbow.apply_to(self.led_data) diff --git a/snippets/robot/CANPDP/robot.py b/snippets/robot/CANPDP/robot.py index 26f12feca..0c8650620 100755 --- a/snippets/robot/CANPDP/robot.py +++ b/snippets/robot/CANPDP/robot.py @@ -5,6 +5,8 @@ # the WPILib BSD license file in the root directory of this project. # +from typing import override + import telemetry import wpilib @@ -23,6 +25,7 @@ def __init__(self): # Object for dealing with the Power Distribution Panel (PDP). self.pdp = wpilib.PowerDistribution(wpilib.CANPort.CAN_S0) + @override def robot_periodic(self): # Put the PDP itself to the dashboard telemetry.log("PDP", self.pdp) diff --git a/snippets/robot/DigitalCommunication/robot.py b/snippets/robot/DigitalCommunication/robot.py index c37a954fe..a89e4c0c7 100755 --- a/snippets/robot/DigitalCommunication/robot.py +++ b/snippets/robot/DigitalCommunication/robot.py @@ -5,6 +5,8 @@ # the WPILib BSD license file in the root directory of this project. # +from typing import override + import wpilib @@ -29,6 +31,7 @@ def __init__(self): self.autonomous_output = wpilib.DigitalOutput(self.AUTONOMOUS_PORT) self.alert_output = wpilib.DigitalOutput(self.ALERT_PORT) + @override def robot_periodic(self): set_alliance = False alliance = wpilib.MatchState.get_alliance() diff --git a/snippets/robot/DutyCycleInput/robot.py b/snippets/robot/DutyCycleInput/robot.py index be110bee9..554cf5275 100755 --- a/snippets/robot/DutyCycleInput/robot.py +++ b/snippets/robot/DutyCycleInput/robot.py @@ -5,6 +5,8 @@ # the WPILib BSD license file in the root directory of this project. # +from typing import override + import telemetry import wpilib @@ -16,6 +18,7 @@ def __init__(self): self.duty_cycle = wpilib.DutyCycle(0) + @override def robot_periodic(self): # Duty Cycle Frequency in Hz frequency = self.duty_cycle.get_frequency() diff --git a/snippets/robot/EventLoop/robot.py b/snippets/robot/EventLoop/robot.py index 6a4724824..46f7feff5 100644 --- a/snippets/robot/EventLoop/robot.py +++ b/snippets/robot/EventLoop/robot.py @@ -5,6 +5,8 @@ # the WPILib BSD license file in the root directory of this project. # +from typing import override + import wpilib import wpilib_drivers import wpimath @@ -85,6 +87,7 @@ def __init__(self) -> None: lambda: self.kicker.set_throttle(0.0) ) + @override def robot_periodic(self) -> None: # poll all the bindings self.loop.poll() diff --git a/snippets/robot/FlywheelBangBangController/robot.py b/snippets/robot/FlywheelBangBangController/robot.py index 27fbd20db..d9b2ec413 100755 --- a/snippets/robot/FlywheelBangBangController/robot.py +++ b/snippets/robot/FlywheelBangBangController/robot.py @@ -5,13 +5,14 @@ # the WPILib BSD license file in the root directory of this project. # +import math +from typing import override + import telemetry import tunables import wpilib -import wpilib_drivers -import math - import wpilib.simulation +import wpilib_drivers import wpimath import wpimath.units @@ -75,9 +76,11 @@ def __init__(self) -> None: tunables.publish("BangBang Controller", self.bang_bang_controler) + @override def robot_periodic(self) -> None: telemetry.log("BangBang Controller", self.bang_bang_controler) + @override def teleop_periodic(self) -> None: """Controls flywheel to a set velocity (RPM) controlled by a joystick.""" @@ -102,6 +105,7 @@ def teleop_periodic(self) -> None: bang_output + 0.9 * self.feedforward.calculate(setpoint) ) + @override def simulation_periodic(self) -> None: """Update our simulation. This should be run every robot loop in simulation.""" # To update our simulation, we set motor voltage inputs, update the diff --git a/snippets/robot/GameData2026/robot.py b/snippets/robot/GameData2026/robot.py index 8da5a51bb..127b59068 100644 --- a/snippets/robot/GameData2026/robot.py +++ b/snippets/robot/GameData2026/robot.py @@ -5,6 +5,8 @@ # the WPILib BSD license file in the root directory of this project. # +from typing import override + import telemetry import wpilib @@ -66,6 +68,7 @@ def is_hub_active(self) -> bool: else: return True # End game, hub always active + @override def teleop_periodic(self): telemetry.log("Hub active", self.is_hub_active()) telemetry.log("Match time", wpilib.MatchState.get_match_time()) diff --git a/snippets/robot/I2CCommunication/robot.py b/snippets/robot/I2CCommunication/robot.py index 1e4b6252f..93e6852f2 100755 --- a/snippets/robot/I2CCommunication/robot.py +++ b/snippets/robot/I2CCommunication/robot.py @@ -5,6 +5,8 @@ # the WPILib BSD license file in the root directory of this project. # +from typing import override + import wpilib @@ -30,6 +32,7 @@ def write_string(self, s: str): # Writes bytes over I2C self.arduino.write_bulk(chars) + @override def robot_periodic(self): # Creates a string to hold current robot state information, including # alliance, enabled state, operation mode, and match time. The message diff --git a/snippets/robot/MotorControl/robot.py b/snippets/robot/MotorControl/robot.py index 573ffab0a..852ab5358 100755 --- a/snippets/robot/MotorControl/robot.py +++ b/snippets/robot/MotorControl/robot.py @@ -5,6 +5,8 @@ # the WPILib BSD license file in the root directory of this project. # +from typing import override + import telemetry import wpilib import wpilib_drivers @@ -53,9 +55,11 @@ def __init__(self): self.motor.set_expiration(0.1) self.motor.feed() + @override def robot_periodic(self): """The robot_periodic function is called every control packet no matter the robot mode.""" telemetry.log("Encoder", self.encoder.get_distance()) + @override def teleop_periodic(self): self.motor.set_throttle(self.joystick.get_y()) diff --git a/snippets/robot/SelectCommand/robot.py b/snippets/robot/SelectCommand/robot.py index bccd78154..905a0de18 100644 --- a/snippets/robot/SelectCommand/robot.py +++ b/snippets/robot/SelectCommand/robot.py @@ -5,9 +5,9 @@ # the WPILib BSD license file in the root directory of this project. # -import wpilib +from typing import override + import commands2 -import typing from robotcontainer import RobotContainer @@ -18,7 +18,7 @@ class MyRobot(commands2.TimedCommandRobot): has an implementation of robot_periodic which runs the scheduler for you """ - autonomous_command: typing.Optional[commands2.Command] = None + autonomous_command: commands2.Command | None = None def __init__(self) -> None: """ @@ -31,14 +31,17 @@ def __init__(self) -> None: # autonomous chooser on the dashboard. self.container = RobotContainer() + @override def disabled_init(self) -> None: """This function is called once each time the robot enters Disabled mode.""" pass + @override def disabled_periodic(self) -> None: """This function is called periodically when disabled""" pass + @override def autonomous_init(self) -> None: """This autonomous runs the autonomous command selected by your RobotContainer class.""" self.autonomous_command = self.container.get_autonomous_command() @@ -46,10 +49,12 @@ def autonomous_init(self) -> None: if self.autonomous_command: self.autonomous_command.schedule() + @override def autonomous_periodic(self) -> None: """This function is called periodically during autonomous""" pass + @override def teleop_init(self) -> None: # This makes sure that the autonomous stops running when # teleop starts running. If you want the autonomous to @@ -58,10 +63,12 @@ def teleop_init(self) -> None: if self.autonomous_command: self.autonomous_command.cancel() + @override def teleop_periodic(self) -> None: """This function is called periodically during operator control""" pass + @override def utility_init(self) -> None: # Cancels all running commands at the start of utility mode commands2.CommandScheduler.get_instance().cancel_all() diff --git a/snippets/robot/Solenoid/robot.py b/snippets/robot/Solenoid/robot.py index 377a0949b..14de25574 100644 --- a/snippets/robot/Solenoid/robot.py +++ b/snippets/robot/Solenoid/robot.py @@ -5,6 +5,8 @@ # the WPILib BSD license file in the root directory of this project. # +from typing import override + import telemetry import wpilib @@ -54,6 +56,7 @@ def __init__(self) -> None: module_type=wpilib.PneumaticsModuleType.REV_PH, ) + @override def teleop_periodic(self) -> None: # Publish some raw data # Get the pressure (in PSI) from the analog sensor connected to the PH. diff --git a/subprojects/pyntcore/devtools/gen-pubsub.py b/subprojects/pyntcore/devtools/gen-pubsub.py index 753b56eee..71fe47b98 100755 --- a/subprojects/pyntcore/devtools/gen-pubsub.py +++ b/subprojects/pyntcore/devtools/gen-pubsub.py @@ -2,7 +2,6 @@ import sphinxify from cxxheaderparser.simple import parse_string -from cxxheaderparser.tokfmt import tokfmt if __name__ == "__main__": with open("ntcore/src/main/native/include/wpi/nt/ntcore_cpp.hpp") as fp: diff --git a/subprojects/pyntcore/ntcore/types.py b/subprojects/pyntcore/ntcore/types.py index 8105039b4..f5d470e30 100644 --- a/subprojects/pyntcore/ntcore/types.py +++ b/subprojects/pyntcore/ntcore/types.py @@ -1,13 +1,13 @@ -from typing import Sequence, Union +from collections.abc import Sequence -ValueT = Union[ - bool, - int, - float, - str, - bytes, - Sequence[bool], - Sequence[int], - Sequence[float], - Sequence[str], -] +ValueT = ( + bool + | int + | float + | str + | bytes + | Sequence[bool] + | Sequence[int] + | Sequence[float] + | Sequence[str] +) diff --git a/subprojects/pyntcore/ntcore/util.py b/subprojects/pyntcore/ntcore/util.py index 418e917e6..efe3c1645 100644 --- a/subprojects/pyntcore/ntcore/util.py +++ b/subprojects/pyntcore/ntcore/util.py @@ -1,7 +1,7 @@ import threading import weakref -from typing import Callable, Dict, Optional, Sequence +from collections.abc import Callable, Sequence from ._ntcore import ( EventFlags, @@ -16,7 +16,7 @@ _SENTINEL = object() -def _selection_is_unset(value: Optional[str]) -> bool: +def _selection_is_unset(value: str | None) -> bool: return value is None or value == "" @@ -29,7 +29,7 @@ class _NtProperty: default_value: Value _instlock = threading.Lock() - _instances: Dict[int, weakref.WeakSet] = {} + _instances: dict[int, weakref.WeakSet] = {} @classmethod def attach(cls, self: "_NtProperty", inst: NetworkTableInstance): @@ -59,7 +59,7 @@ def __init__( default_value, write_default: bool, persistent: bool, - type: Optional[NetworkTableType], + type: NetworkTableType | None, inst: NetworkTableInstance, ) -> None: # Autodetect the type if not provided, and store the default @@ -109,8 +109,8 @@ def ntproperty( write_default: bool = True, doc: str = None, persistent: bool = False, - type: Optional[NetworkTableType] = None, - inst: Optional[NetworkTableInstance] = None + type: NetworkTableType | None = None, + inst: NetworkTableInstance | None = None, ) -> property: """ A property that you can add to your classes to access NetworkTables @@ -167,10 +167,10 @@ class SelectableControl: def __init__( self, key: str, - on_choices: Optional[Callable[[Sequence[str]], None]] = None, - on_selected: Optional[Callable[[str], None]] = None, + on_choices: Callable[[Sequence[str]], None] | None = None, + on_selected: Callable[[str], None] | None = None, *, - inst: Optional[NetworkTableInstance] = None + inst: NetworkTableInstance | None = None, ) -> None: """ :param key: NetworkTables key @@ -218,13 +218,13 @@ def get_choices(self) -> Sequence[str]: """ return self.subtable.get_string_array("options", []) - def get_selected(self) -> Optional[str]: + def get_selected(self) -> str | None: """ Returns the current selection or None """ return self._get_effective_selection() - def _get_effective_selection(self) -> Optional[str]: + def _get_effective_selection(self) -> str | None: selected = self.selected_subtable.get_string("value", None) if _selection_is_unset(selected): selected = self.selected_subtable.get_string("tune", None) diff --git a/subprojects/pyntcore/pyproject.in.toml b/subprojects/pyntcore/pyproject.in.toml index 1e874bc2c..3b56f073a 100644 --- a/subprojects/pyntcore/pyproject.in.toml +++ b/subprojects/pyntcore/pyproject.in.toml @@ -6,8 +6,8 @@ requires = [ "hatch-robotpy==0.0.0", "hatchling", "robotpy-native-ntcore==0.0.0", + "robotpy-native-wpinet==0.0.0", "robotpy-wpiutil==0.0.0", - "robotpy-wpinet==0.0.0", "robotpy-wpilog==0.0.0", ] @@ -16,15 +16,15 @@ requires = [ name = "pyntcore" version = "0.0.0" description = "Binary wrappers for the FIRST ntcore library" -requires-python = ">=3.11" +requires-python = ">=3.12" authors = [ {name = "RobotPy Development Team", email = "robotpy@googlegroups.com"}, ] license = "BSD-3-Clause" dependencies = [ "robotpy-native-ntcore==0.0.0", + "robotpy-native-wpinet==0.0.0", "robotpy-wpiutil==0.0.0", - "robotpy-wpinet==0.0.0", "robotpy-wpilog==0.0.0", ] diff --git a/subprojects/robotpy-apriltag/pyproject.in.toml b/subprojects/robotpy-apriltag/pyproject.in.toml index 417c01d35..abf9b0c91 100644 --- a/subprojects/robotpy-apriltag/pyproject.in.toml +++ b/subprojects/robotpy-apriltag/pyproject.in.toml @@ -14,7 +14,7 @@ requires = [ name = "robotpy-apriltag" version = "0.0.0" description = "RobotPy bindings for WPILib's AprilTag library" -requires-python = ">=3.11" +requires-python = ">=3.12" authors = [ {name = "RobotPy Development Team", email = "robotpy@googlegroups.com"}, ] diff --git a/subprojects/robotpy-commands-v2/commands2/button/commanddualsensecontroller.py b/subprojects/robotpy-commands-v2/commands2/button/commanddualsensecontroller.py index 2fcd28ca6..0b46d83d4 100644 --- a/subprojects/robotpy-commands-v2/commands2/button/commanddualsensecontroller.py +++ b/subprojects/robotpy-commands-v2/commands2/button/commanddualsensecontroller.py @@ -1,7 +1,5 @@ # THIS FILE WAS AUTO-GENERATED BY ./commandsv2/generate_hids.py. DO NOT MODIFY -from typing import Optional, Union - from wpilib import EventLoop, DualSenseController from .commandgenerichid import CommandGenericHID @@ -16,7 +14,7 @@ class CommandDualSenseController: _hid: CommandGenericHID _controller: DualSenseController - def __init__(self, hid: Union[int, DualSenseController]): + def __init__(self, hid: int | DualSenseController): """ Construct an instance of a controller. @@ -49,7 +47,7 @@ def get_controller(self) -> DualSenseController: def button( self, button: DualSenseController.Button, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs an event instance around this button's digital signal. @@ -59,7 +57,7 @@ def button( """ return self._hid.button(button.value, loop) - def cross(self, loop: Optional[EventLoop] = None) -> Trigger: + def cross(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Cross button's digital signal. @@ -71,7 +69,7 @@ def cross(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(DualSenseController.Button.CROSS, loop) - def circle(self, loop: Optional[EventLoop] = None) -> Trigger: + def circle(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Circle button's digital signal. @@ -83,7 +81,7 @@ def circle(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(DualSenseController.Button.CIRCLE, loop) - def square(self, loop: Optional[EventLoop] = None) -> Trigger: + def square(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Square button's digital signal. @@ -95,7 +93,7 @@ def square(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(DualSenseController.Button.SQUARE, loop) - def triangle(self, loop: Optional[EventLoop] = None) -> Trigger: + def triangle(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Triangle button's digital signal. @@ -107,7 +105,7 @@ def triangle(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(DualSenseController.Button.TRIANGLE, loop) - def create(self, loop: Optional[EventLoop] = None) -> Trigger: + def create(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Create button's digital signal. @@ -119,7 +117,7 @@ def create(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(DualSenseController.Button.CREATE, loop) - def ps(self, loop: Optional[EventLoop] = None) -> Trigger: + def ps(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the PS button's digital signal. @@ -131,7 +129,7 @@ def ps(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(DualSenseController.Button.PS, loop) - def options(self, loop: Optional[EventLoop] = None) -> Trigger: + def options(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Options button's digital signal. @@ -143,7 +141,7 @@ def options(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(DualSenseController.Button.OPTIONS, loop) - def l3(self, loop: Optional[EventLoop] = None) -> Trigger: + def l3(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the L3 button's digital signal. @@ -155,7 +153,7 @@ def l3(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(DualSenseController.Button.L3, loop) - def r3(self, loop: Optional[EventLoop] = None) -> Trigger: + def r3(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the R3 button's digital signal. @@ -167,7 +165,7 @@ def r3(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(DualSenseController.Button.R3, loop) - def l1(self, loop: Optional[EventLoop] = None) -> Trigger: + def l1(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the L1 button's digital signal. @@ -179,7 +177,7 @@ def l1(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(DualSenseController.Button.L1, loop) - def r1(self, loop: Optional[EventLoop] = None) -> Trigger: + def r1(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the R1 button's digital signal. @@ -191,7 +189,7 @@ def r1(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(DualSenseController.Button.R1, loop) - def dpad_up(self, loop: Optional[EventLoop] = None) -> Trigger: + def dpad_up(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Dpad Up button's digital signal. @@ -203,7 +201,7 @@ def dpad_up(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(DualSenseController.Button.DPAD_UP, loop) - def dpad_down(self, loop: Optional[EventLoop] = None) -> Trigger: + def dpad_down(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Dpad Down button's digital signal. @@ -215,7 +213,7 @@ def dpad_down(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(DualSenseController.Button.DPAD_DOWN, loop) - def dpad_left(self, loop: Optional[EventLoop] = None) -> Trigger: + def dpad_left(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Dpad Left button's digital signal. @@ -227,7 +225,7 @@ def dpad_left(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(DualSenseController.Button.DPAD_LEFT, loop) - def dpad_right(self, loop: Optional[EventLoop] = None) -> Trigger: + def dpad_right(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Dpad Right button's digital signal. @@ -239,7 +237,7 @@ def dpad_right(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(DualSenseController.Button.DPAD_RIGHT, loop) - def microphone(self, loop: Optional[EventLoop] = None) -> Trigger: + def microphone(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Microphone button's digital signal. @@ -251,7 +249,7 @@ def microphone(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(DualSenseController.Button.MICROPHONE, loop) - def touchpad(self, loop: Optional[EventLoop] = None) -> Trigger: + def touchpad(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Touchpad button's digital signal. @@ -266,7 +264,7 @@ def touchpad(self, loop: Optional[EventLoop] = None) -> Trigger: def l2( self, threshold: float = 0.5, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs a Trigger instance around the L2 axis value. The returned @@ -289,7 +287,7 @@ def l2( def r2( self, threshold: float = 0.5, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs a Trigger instance around the R2 axis value. The returned @@ -313,7 +311,7 @@ def axis_less_than( self, axis: DualSenseController.Axis, threshold: float, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs a Trigger instance that is true when the axis value is less than @@ -332,7 +330,7 @@ def axis_greater_than( self, axis: DualSenseController.Axis, threshold: float, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs a Trigger instance that is true when the axis value is greater @@ -351,7 +349,7 @@ def axis_magnitude_greater_than( self, axis: DualSenseController.Axis, threshold: float, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs a Trigger instance that is true when the axis magnitude is diff --git a/subprojects/robotpy-commands-v2/commands2/button/commanddualsenseedgecontroller.py b/subprojects/robotpy-commands-v2/commands2/button/commanddualsenseedgecontroller.py index 773ed3ff4..2a4539794 100644 --- a/subprojects/robotpy-commands-v2/commands2/button/commanddualsenseedgecontroller.py +++ b/subprojects/robotpy-commands-v2/commands2/button/commanddualsenseedgecontroller.py @@ -1,7 +1,5 @@ # THIS FILE WAS AUTO-GENERATED BY ./commandsv2/generate_hids.py. DO NOT MODIFY -from typing import Optional, Union - from wpilib import EventLoop, DualSenseEdgeController from .commandgenerichid import CommandGenericHID @@ -16,7 +14,7 @@ class CommandDualSenseEdgeController: _hid: CommandGenericHID _controller: DualSenseEdgeController - def __init__(self, hid: Union[int, DualSenseEdgeController]): + def __init__(self, hid: int | DualSenseEdgeController): """ Construct an instance of a controller. @@ -49,7 +47,7 @@ def get_controller(self) -> DualSenseEdgeController: def button( self, button: DualSenseEdgeController.Button, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs an event instance around this button's digital signal. @@ -59,7 +57,7 @@ def button( """ return self._hid.button(button.value, loop) - def cross(self, loop: Optional[EventLoop] = None) -> Trigger: + def cross(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Cross button's digital signal. @@ -71,7 +69,7 @@ def cross(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(DualSenseEdgeController.Button.CROSS, loop) - def circle(self, loop: Optional[EventLoop] = None) -> Trigger: + def circle(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Circle button's digital signal. @@ -83,7 +81,7 @@ def circle(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(DualSenseEdgeController.Button.CIRCLE, loop) - def square(self, loop: Optional[EventLoop] = None) -> Trigger: + def square(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Square button's digital signal. @@ -95,7 +93,7 @@ def square(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(DualSenseEdgeController.Button.SQUARE, loop) - def triangle(self, loop: Optional[EventLoop] = None) -> Trigger: + def triangle(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Triangle button's digital signal. @@ -107,7 +105,7 @@ def triangle(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(DualSenseEdgeController.Button.TRIANGLE, loop) - def create(self, loop: Optional[EventLoop] = None) -> Trigger: + def create(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Create button's digital signal. @@ -119,7 +117,7 @@ def create(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(DualSenseEdgeController.Button.CREATE, loop) - def ps(self, loop: Optional[EventLoop] = None) -> Trigger: + def ps(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the PS button's digital signal. @@ -131,7 +129,7 @@ def ps(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(DualSenseEdgeController.Button.PS, loop) - def options(self, loop: Optional[EventLoop] = None) -> Trigger: + def options(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Options button's digital signal. @@ -143,7 +141,7 @@ def options(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(DualSenseEdgeController.Button.OPTIONS, loop) - def l3(self, loop: Optional[EventLoop] = None) -> Trigger: + def l3(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the L3 button's digital signal. @@ -155,7 +153,7 @@ def l3(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(DualSenseEdgeController.Button.L3, loop) - def r3(self, loop: Optional[EventLoop] = None) -> Trigger: + def r3(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the R3 button's digital signal. @@ -167,7 +165,7 @@ def r3(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(DualSenseEdgeController.Button.R3, loop) - def l1(self, loop: Optional[EventLoop] = None) -> Trigger: + def l1(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the L1 button's digital signal. @@ -179,7 +177,7 @@ def l1(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(DualSenseEdgeController.Button.L1, loop) - def r1(self, loop: Optional[EventLoop] = None) -> Trigger: + def r1(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the R1 button's digital signal. @@ -191,7 +189,7 @@ def r1(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(DualSenseEdgeController.Button.R1, loop) - def dpad_up(self, loop: Optional[EventLoop] = None) -> Trigger: + def dpad_up(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Dpad Up button's digital signal. @@ -203,7 +201,7 @@ def dpad_up(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(DualSenseEdgeController.Button.DPAD_UP, loop) - def dpad_down(self, loop: Optional[EventLoop] = None) -> Trigger: + def dpad_down(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Dpad Down button's digital signal. @@ -215,7 +213,7 @@ def dpad_down(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(DualSenseEdgeController.Button.DPAD_DOWN, loop) - def dpad_left(self, loop: Optional[EventLoop] = None) -> Trigger: + def dpad_left(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Dpad Left button's digital signal. @@ -227,7 +225,7 @@ def dpad_left(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(DualSenseEdgeController.Button.DPAD_LEFT, loop) - def dpad_right(self, loop: Optional[EventLoop] = None) -> Trigger: + def dpad_right(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Dpad Right button's digital signal. @@ -239,7 +237,7 @@ def dpad_right(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(DualSenseEdgeController.Button.DPAD_RIGHT, loop) - def microphone(self, loop: Optional[EventLoop] = None) -> Trigger: + def microphone(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Microphone button's digital signal. @@ -251,7 +249,7 @@ def microphone(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(DualSenseEdgeController.Button.MICROPHONE, loop) - def right_paddle1(self, loop: Optional[EventLoop] = None) -> Trigger: + def right_paddle1(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Right Paddle 1 button's digital signal. @@ -263,7 +261,7 @@ def right_paddle1(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(DualSenseEdgeController.Button.RIGHT_PADDLE_1, loop) - def left_paddle1(self, loop: Optional[EventLoop] = None) -> Trigger: + def left_paddle1(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Left Paddle 1 button's digital signal. @@ -275,7 +273,7 @@ def left_paddle1(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(DualSenseEdgeController.Button.LEFT_PADDLE_1, loop) - def touchpad(self, loop: Optional[EventLoop] = None) -> Trigger: + def touchpad(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Touchpad button's digital signal. @@ -287,7 +285,7 @@ def touchpad(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(DualSenseEdgeController.Button.TOUCHPAD, loop) - def left_function(self, loop: Optional[EventLoop] = None) -> Trigger: + def left_function(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Left Function button's digital signal. @@ -299,7 +297,7 @@ def left_function(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(DualSenseEdgeController.Button.LEFT_FUNCTION, loop) - def right_function(self, loop: Optional[EventLoop] = None) -> Trigger: + def right_function(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Right Function button's digital signal. @@ -314,7 +312,7 @@ def right_function(self, loop: Optional[EventLoop] = None) -> Trigger: def l2( self, threshold: float = 0.5, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs a Trigger instance around the L2 axis value. The returned @@ -337,7 +335,7 @@ def l2( def r2( self, threshold: float = 0.5, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs a Trigger instance around the R2 axis value. The returned @@ -361,7 +359,7 @@ def axis_less_than( self, axis: DualSenseEdgeController.Axis, threshold: float, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs a Trigger instance that is true when the axis value is less than @@ -380,7 +378,7 @@ def axis_greater_than( self, axis: DualSenseEdgeController.Axis, threshold: float, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs a Trigger instance that is true when the axis value is greater @@ -399,7 +397,7 @@ def axis_magnitude_greater_than( self, axis: DualSenseEdgeController.Axis, threshold: float, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs a Trigger instance that is true when the axis magnitude is diff --git a/subprojects/robotpy-commands-v2/commands2/button/commanddualshock4controller.py b/subprojects/robotpy-commands-v2/commands2/button/commanddualshock4controller.py index 5681ea21c..a34bd7f4e 100644 --- a/subprojects/robotpy-commands-v2/commands2/button/commanddualshock4controller.py +++ b/subprojects/robotpy-commands-v2/commands2/button/commanddualshock4controller.py @@ -1,7 +1,5 @@ # THIS FILE WAS AUTO-GENERATED BY ./commandsv2/generate_hids.py. DO NOT MODIFY -from typing import Optional, Union - from wpilib import EventLoop, DualShock4Controller from .commandgenerichid import CommandGenericHID @@ -16,7 +14,7 @@ class CommandDualShock4Controller: _hid: CommandGenericHID _controller: DualShock4Controller - def __init__(self, hid: Union[int, DualShock4Controller]): + def __init__(self, hid: int | DualShock4Controller): """ Construct an instance of a controller. @@ -49,7 +47,7 @@ def get_controller(self) -> DualShock4Controller: def button( self, button: DualShock4Controller.Button, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs an event instance around this button's digital signal. @@ -59,7 +57,7 @@ def button( """ return self._hid.button(button.value, loop) - def cross(self, loop: Optional[EventLoop] = None) -> Trigger: + def cross(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Cross button's digital signal. @@ -71,7 +69,7 @@ def cross(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(DualShock4Controller.Button.CROSS, loop) - def circle(self, loop: Optional[EventLoop] = None) -> Trigger: + def circle(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Circle button's digital signal. @@ -83,7 +81,7 @@ def circle(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(DualShock4Controller.Button.CIRCLE, loop) - def square(self, loop: Optional[EventLoop] = None) -> Trigger: + def square(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Square button's digital signal. @@ -95,7 +93,7 @@ def square(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(DualShock4Controller.Button.SQUARE, loop) - def triangle(self, loop: Optional[EventLoop] = None) -> Trigger: + def triangle(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Triangle button's digital signal. @@ -107,7 +105,7 @@ def triangle(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(DualShock4Controller.Button.TRIANGLE, loop) - def share(self, loop: Optional[EventLoop] = None) -> Trigger: + def share(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Share button's digital signal. @@ -119,7 +117,7 @@ def share(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(DualShock4Controller.Button.SHARE, loop) - def ps(self, loop: Optional[EventLoop] = None) -> Trigger: + def ps(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the PS button's digital signal. @@ -131,7 +129,7 @@ def ps(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(DualShock4Controller.Button.PS, loop) - def options(self, loop: Optional[EventLoop] = None) -> Trigger: + def options(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Options button's digital signal. @@ -143,7 +141,7 @@ def options(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(DualShock4Controller.Button.OPTIONS, loop) - def l3(self, loop: Optional[EventLoop] = None) -> Trigger: + def l3(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the L3 button's digital signal. @@ -155,7 +153,7 @@ def l3(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(DualShock4Controller.Button.L3, loop) - def r3(self, loop: Optional[EventLoop] = None) -> Trigger: + def r3(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the R3 button's digital signal. @@ -167,7 +165,7 @@ def r3(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(DualShock4Controller.Button.R3, loop) - def l1(self, loop: Optional[EventLoop] = None) -> Trigger: + def l1(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the L1 button's digital signal. @@ -179,7 +177,7 @@ def l1(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(DualShock4Controller.Button.L1, loop) - def r1(self, loop: Optional[EventLoop] = None) -> Trigger: + def r1(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the R1 button's digital signal. @@ -191,7 +189,7 @@ def r1(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(DualShock4Controller.Button.R1, loop) - def dpad_up(self, loop: Optional[EventLoop] = None) -> Trigger: + def dpad_up(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Dpad Up button's digital signal. @@ -203,7 +201,7 @@ def dpad_up(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(DualShock4Controller.Button.DPAD_UP, loop) - def dpad_down(self, loop: Optional[EventLoop] = None) -> Trigger: + def dpad_down(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Dpad Down button's digital signal. @@ -215,7 +213,7 @@ def dpad_down(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(DualShock4Controller.Button.DPAD_DOWN, loop) - def dpad_left(self, loop: Optional[EventLoop] = None) -> Trigger: + def dpad_left(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Dpad Left button's digital signal. @@ -227,7 +225,7 @@ def dpad_left(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(DualShock4Controller.Button.DPAD_LEFT, loop) - def dpad_right(self, loop: Optional[EventLoop] = None) -> Trigger: + def dpad_right(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Dpad Right button's digital signal. @@ -239,7 +237,7 @@ def dpad_right(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(DualShock4Controller.Button.DPAD_RIGHT, loop) - def touchpad(self, loop: Optional[EventLoop] = None) -> Trigger: + def touchpad(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Touchpad button's digital signal. @@ -254,7 +252,7 @@ def touchpad(self, loop: Optional[EventLoop] = None) -> Trigger: def l2( self, threshold: float = 0.5, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs a Trigger instance around the L2 axis value. The returned @@ -277,7 +275,7 @@ def l2( def r2( self, threshold: float = 0.5, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs a Trigger instance around the R2 axis value. The returned @@ -301,7 +299,7 @@ def axis_less_than( self, axis: DualShock4Controller.Axis, threshold: float, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs a Trigger instance that is true when the axis value is less than @@ -320,7 +318,7 @@ def axis_greater_than( self, axis: DualShock4Controller.Axis, threshold: float, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs a Trigger instance that is true when the axis value is greater @@ -339,7 +337,7 @@ def axis_magnitude_greater_than( self, axis: DualShock4Controller.Axis, threshold: float, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs a Trigger instance that is true when the axis magnitude is diff --git a/subprojects/robotpy-commands-v2/commands2/button/commandgamecubecontroller.py b/subprojects/robotpy-commands-v2/commands2/button/commandgamecubecontroller.py index 872bd6fb0..c8fcd9130 100644 --- a/subprojects/robotpy-commands-v2/commands2/button/commandgamecubecontroller.py +++ b/subprojects/robotpy-commands-v2/commands2/button/commandgamecubecontroller.py @@ -1,7 +1,5 @@ # THIS FILE WAS AUTO-GENERATED BY ./commandsv2/generate_hids.py. DO NOT MODIFY -from typing import Optional, Union - from wpilib import EventLoop, GameCubeController from .commandgenerichid import CommandGenericHID @@ -16,7 +14,7 @@ class CommandGameCubeController: _hid: CommandGenericHID _controller: GameCubeController - def __init__(self, hid: Union[int, GameCubeController]): + def __init__(self, hid: int | GameCubeController): """ Construct an instance of a controller. @@ -49,7 +47,7 @@ def get_controller(self) -> GameCubeController: def button( self, button: GameCubeController.Button, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs an event instance around this button's digital signal. @@ -59,7 +57,7 @@ def button( """ return self._hid.button(button.value, loop) - def a(self, loop: Optional[EventLoop] = None) -> Trigger: + def a(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the A button's digital signal. @@ -71,7 +69,7 @@ def a(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(GameCubeController.Button.A, loop) - def x(self, loop: Optional[EventLoop] = None) -> Trigger: + def x(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the X button's digital signal. @@ -83,7 +81,7 @@ def x(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(GameCubeController.Button.X, loop) - def b(self, loop: Optional[EventLoop] = None) -> Trigger: + def b(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the B button's digital signal. @@ -95,7 +93,7 @@ def b(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(GameCubeController.Button.B, loop) - def y(self, loop: Optional[EventLoop] = None) -> Trigger: + def y(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Y button's digital signal. @@ -107,7 +105,7 @@ def y(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(GameCubeController.Button.Y, loop) - def start(self, loop: Optional[EventLoop] = None) -> Trigger: + def start(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Start button's digital signal. @@ -119,7 +117,7 @@ def start(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(GameCubeController.Button.START, loop) - def z(self, loop: Optional[EventLoop] = None) -> Trigger: + def z(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Z button's digital signal. @@ -131,7 +129,7 @@ def z(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(GameCubeController.Button.Z, loop) - def dpad_up(self, loop: Optional[EventLoop] = None) -> Trigger: + def dpad_up(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Dpad Up button's digital signal. @@ -143,7 +141,7 @@ def dpad_up(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(GameCubeController.Button.DPAD_UP, loop) - def dpad_down(self, loop: Optional[EventLoop] = None) -> Trigger: + def dpad_down(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Dpad Down button's digital signal. @@ -155,7 +153,7 @@ def dpad_down(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(GameCubeController.Button.DPAD_DOWN, loop) - def dpad_left(self, loop: Optional[EventLoop] = None) -> Trigger: + def dpad_left(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Dpad Left button's digital signal. @@ -167,7 +165,7 @@ def dpad_left(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(GameCubeController.Button.DPAD_LEFT, loop) - def dpad_right(self, loop: Optional[EventLoop] = None) -> Trigger: + def dpad_right(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Dpad Right button's digital signal. @@ -179,7 +177,7 @@ def dpad_right(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(GameCubeController.Button.DPAD_RIGHT, loop) - def l(self, loop: Optional[EventLoop] = None) -> Trigger: + def l(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the L button's digital signal. @@ -191,7 +189,7 @@ def l(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(GameCubeController.Button.L, loop) - def r(self, loop: Optional[EventLoop] = None) -> Trigger: + def r(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the R button's digital signal. @@ -206,7 +204,7 @@ def r(self, loop: Optional[EventLoop] = None) -> Trigger: def l_trigger( self, threshold: float = 0.5, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs a Trigger instance around the L Trigger axis value. The returned @@ -229,7 +227,7 @@ def l_trigger( def r_trigger( self, threshold: float = 0.5, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs a Trigger instance around the R Trigger axis value. The returned @@ -253,7 +251,7 @@ def axis_less_than( self, axis: GameCubeController.Axis, threshold: float, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs a Trigger instance that is true when the axis value is less than @@ -272,7 +270,7 @@ def axis_greater_than( self, axis: GameCubeController.Axis, threshold: float, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs a Trigger instance that is true when the axis value is greater @@ -291,7 +289,7 @@ def axis_magnitude_greater_than( self, axis: GameCubeController.Axis, threshold: float, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs a Trigger instance that is true when the axis magnitude is diff --git a/subprojects/robotpy-commands-v2/commands2/button/commandgamepad.py b/subprojects/robotpy-commands-v2/commands2/button/commandgamepad.py index 5e578b6c0..66a109699 100644 --- a/subprojects/robotpy-commands-v2/commands2/button/commandgamepad.py +++ b/subprojects/robotpy-commands-v2/commands2/button/commandgamepad.py @@ -1,5 +1,4 @@ # validated: 2024-01-20 DS 92149efa11fa button/CommandGamepad.java -from typing import Optional, Union from wpilib import DriverStation, EventLoop, Gamepad @@ -22,7 +21,7 @@ class CommandGamepad: _hid: CommandGenericHID _gamepad: Gamepad - def __init__(self, hid: Union[int, Gamepad]): + def __init__(self, hid: int | Gamepad): """ Construct an instance of a controller. @@ -56,7 +55,7 @@ def get_gamepad(self) -> Gamepad: """ return self._gamepad - def button(self, button, loop: Optional[EventLoop] = None) -> Trigger: + def button(self, button, loop: EventLoop | None = None) -> Trigger: """ Constructs an event instance around this button's digital signal. @@ -65,106 +64,106 @@ def button(self, button, loop: Optional[EventLoop] = None) -> Trigger: """ return self._hid.button(_enum_value(button), loop) - def face_down(self, loop: Optional[EventLoop] = None) -> Trigger: + def face_down(self, loop: EventLoop | None = None) -> Trigger: return self.button(Gamepad.Button.FACE_DOWN, loop) - def face_right(self, loop: Optional[EventLoop] = None) -> Trigger: + def face_right(self, loop: EventLoop | None = None) -> Trigger: return self.button(Gamepad.Button.FACE_RIGHT, loop) - def face_left(self, loop: Optional[EventLoop] = None) -> Trigger: + def face_left(self, loop: EventLoop | None = None) -> Trigger: return self.button(Gamepad.Button.FACE_LEFT, loop) - def face_up(self, loop: Optional[EventLoop] = None) -> Trigger: + def face_up(self, loop: EventLoop | None = None) -> Trigger: return self.button(Gamepad.Button.FACE_UP, loop) - def back(self, loop: Optional[EventLoop] = None) -> Trigger: + def back(self, loop: EventLoop | None = None) -> Trigger: return self.button(Gamepad.Button.BACK, loop) - def guide(self, loop: Optional[EventLoop] = None) -> Trigger: + def guide(self, loop: EventLoop | None = None) -> Trigger: return self.button(Gamepad.Button.GUIDE, loop) - def start(self, loop: Optional[EventLoop] = None) -> Trigger: + def start(self, loop: EventLoop | None = None) -> Trigger: return self.button(Gamepad.Button.START, loop) - def left_stick(self, loop: Optional[EventLoop] = None) -> Trigger: + def left_stick(self, loop: EventLoop | None = None) -> Trigger: return self.button(Gamepad.Button.LEFT_STICK, loop) - def right_stick(self, loop: Optional[EventLoop] = None) -> Trigger: + def right_stick(self, loop: EventLoop | None = None) -> Trigger: return self.button(Gamepad.Button.RIGHT_STICK, loop) - def left_bumper(self, loop: Optional[EventLoop] = None) -> Trigger: + def left_bumper(self, loop: EventLoop | None = None) -> Trigger: return self.button(Gamepad.Button.LEFT_BUMPER, loop) - def right_bumper(self, loop: Optional[EventLoop] = None) -> Trigger: + def right_bumper(self, loop: EventLoop | None = None) -> Trigger: return self.button(Gamepad.Button.RIGHT_BUMPER, loop) - def dpad_up(self, loop: Optional[EventLoop] = None) -> Trigger: + def dpad_up(self, loop: EventLoop | None = None) -> Trigger: return self.button(Gamepad.Button.DPAD_UP, loop) - def dpad_down(self, loop: Optional[EventLoop] = None) -> Trigger: + def dpad_down(self, loop: EventLoop | None = None) -> Trigger: return self.button(Gamepad.Button.DPAD_DOWN, loop) - def dpad_left(self, loop: Optional[EventLoop] = None) -> Trigger: + def dpad_left(self, loop: EventLoop | None = None) -> Trigger: return self.button(Gamepad.Button.DPAD_LEFT, loop) - def dpad_right(self, loop: Optional[EventLoop] = None) -> Trigger: + def dpad_right(self, loop: EventLoop | None = None) -> Trigger: return self.button(Gamepad.Button.DPAD_RIGHT, loop) - def misc1(self, loop: Optional[EventLoop] = None) -> Trigger: + def misc1(self, loop: EventLoop | None = None) -> Trigger: return self.button(Gamepad.Button.MISC_1, loop) - def right_paddle1(self, loop: Optional[EventLoop] = None) -> Trigger: + def right_paddle1(self, loop: EventLoop | None = None) -> Trigger: return self.button(Gamepad.Button.RIGHT_PADDLE_1, loop) - def left_paddle1(self, loop: Optional[EventLoop] = None) -> Trigger: + def left_paddle1(self, loop: EventLoop | None = None) -> Trigger: return self.button(Gamepad.Button.LEFT_PADDLE_1, loop) - def right_paddle2(self, loop: Optional[EventLoop] = None) -> Trigger: + def right_paddle2(self, loop: EventLoop | None = None) -> Trigger: return self.button(Gamepad.Button.RIGHT_PADDLE_2, loop) - def left_paddle2(self, loop: Optional[EventLoop] = None) -> Trigger: + def left_paddle2(self, loop: EventLoop | None = None) -> Trigger: return self.button(Gamepad.Button.LEFT_PADDLE_2, loop) - def touchpad(self, loop: Optional[EventLoop] = None) -> Trigger: + def touchpad(self, loop: EventLoop | None = None) -> Trigger: return self.button(Gamepad.Button.TOUCHPAD, loop) - def misc2(self, loop: Optional[EventLoop] = None) -> Trigger: + def misc2(self, loop: EventLoop | None = None) -> Trigger: return self.button(Gamepad.Button.MISC_2, loop) - def misc3(self, loop: Optional[EventLoop] = None) -> Trigger: + def misc3(self, loop: EventLoop | None = None) -> Trigger: return self.button(Gamepad.Button.MISC_3, loop) - def misc4(self, loop: Optional[EventLoop] = None) -> Trigger: + def misc4(self, loop: EventLoop | None = None) -> Trigger: return self.button(Gamepad.Button.MISC_4, loop) - def misc5(self, loop: Optional[EventLoop] = None) -> Trigger: + def misc5(self, loop: EventLoop | None = None) -> Trigger: return self.button(Gamepad.Button.MISC_5, loop) - def misc6(self, loop: Optional[EventLoop] = None) -> Trigger: + def misc6(self, loop: EventLoop | None = None) -> Trigger: return self.button(Gamepad.Button.MISC_6, loop) def left_trigger( - self, threshold: float = 0.5, loop: Optional[EventLoop] = None + self, threshold: float = 0.5, loop: EventLoop | None = None ) -> Trigger: return self.axis_greater_than(Gamepad.Axis.LEFT_TRIGGER, threshold, loop) def right_trigger( - self, threshold: float = 0.5, loop: Optional[EventLoop] = None + self, threshold: float = 0.5, loop: EventLoop | None = None ) -> Trigger: return self.axis_greater_than(Gamepad.Axis.RIGHT_TRIGGER, threshold, loop) def axis_less_than( - self, axis, threshold: float, loop: Optional[EventLoop] = None + self, axis, threshold: float, loop: EventLoop | None = None ) -> Trigger: return self._hid.axis_less_than(_enum_value(axis), threshold, loop) def axis_greater_than( - self, axis, threshold: float, loop: Optional[EventLoop] = None + self, axis, threshold: float, loop: EventLoop | None = None ) -> Trigger: return self._hid.axis_greater_than(_enum_value(axis), threshold, loop) def axis_magnitude_greater_than( - self, axis, threshold: float, loop: Optional[EventLoop] = None + self, axis, threshold: float, loop: EventLoop | None = None ) -> Trigger: return self._hid.axis_magnitude_greater_than(_enum_value(axis), threshold, loop) diff --git a/subprojects/robotpy-commands-v2/commands2/button/commandgenerichid.py b/subprojects/robotpy-commands-v2/commands2/button/commandgenerichid.py index b79ee6e3c..4c7dea168 100644 --- a/subprojects/robotpy-commands-v2/commands2/button/commandgenerichid.py +++ b/subprojects/robotpy-commands-v2/commands2/button/commandgenerichid.py @@ -1,6 +1,6 @@ # validated: 2024-01-20 DS 92149efa11fa button/CommandGenericHID.java import threading -from typing import ClassVar, Optional, Union, final +from typing import ClassVar, final from wpilib import DriverStation, EventLoop, GenericHID @@ -17,7 +17,7 @@ class CommandGenericHID: _hids: ClassVar[dict[int, "CommandGenericHID"]] = {} _hids_lock = threading.Lock() - def __init__(self, hid: Union[int, GenericHID]): + def __init__(self, hid: int | GenericHID): """ Construct an instance of a device. @@ -47,7 +47,7 @@ def get_hid(self) -> GenericHID: """ return self._hid - def button(self, button: int, loop: Optional[EventLoop] = None) -> Trigger: + def button(self, button: int, loop: EventLoop | None = None) -> Trigger: """ Constructs an event instance around this button's digital signal. @@ -62,7 +62,7 @@ def button(self, button: int, loop: Optional[EventLoop] = None) -> Trigger: return Trigger(loop, lambda: self._hid.get_raw_button(button)) def pov( - self, angle: int, *, pov: int = 0, loop: Optional[EventLoop] = None + self, angle: int, *, pov: int = 0, loop: EventLoop | None = None ) -> Trigger: """ Constructs a Trigger instance based around this angle of a POV on the HID. @@ -163,7 +163,7 @@ def pov_center(self) -> Trigger: return self.pov(-1) def axis_less_than( - self, axis: int, threshold: float, loop: Optional[EventLoop] = None + self, axis: int, threshold: float, loop: EventLoop | None = None ) -> Trigger: """ Constructs a Trigger instance that is true when the axis value is less than ``threshold``, @@ -181,7 +181,7 @@ def axis_less_than( return Trigger(loop, lambda: self._hid.get_raw_axis(axis) < threshold) def axis_greater_than( - self, axis: int, threshold: float, loop: Optional[EventLoop] = None + self, axis: int, threshold: float, loop: EventLoop | None = None ) -> Trigger: """ Constructs a Trigger instance that is true when the axis value is greater than @@ -199,7 +199,7 @@ def axis_greater_than( return Trigger(loop, lambda: self._hid.get_raw_axis(axis) > threshold) def axis_magnitude_greater_than( - self, axis: int, threshold: float, loop: Optional[EventLoop] = None + self, axis: int, threshold: float, loop: EventLoop | None = None ) -> Trigger: """ Constructs a Trigger instance that is true when the axis magnitude is greater than diff --git a/subprojects/robotpy-commands-v2/commands2/button/commandjoystick.py b/subprojects/robotpy-commands-v2/commands2/button/commandjoystick.py index 68c94c63b..0477705a3 100644 --- a/subprojects/robotpy-commands-v2/commands2/button/commandjoystick.py +++ b/subprojects/robotpy-commands-v2/commands2/button/commandjoystick.py @@ -1,5 +1,4 @@ # validated: 2024-01-20 DS 92aecab2ef05 button/CommandJoystick.java -from typing import Optional from wpilib import EventLoop, Joystick @@ -45,7 +44,7 @@ def get_joystick(self) -> Joystick: """ return self._joystick - def trigger(self, loop: Optional[EventLoop] = None) -> Trigger: + def trigger(self, loop: EventLoop | None = None) -> Trigger: """ Constructs an event instance around the trigger button's digital signal. @@ -59,7 +58,7 @@ def trigger(self, loop: Optional[EventLoop] = None) -> Trigger: loop = CommandScheduler.get_instance().get_default_button_loop() return Trigger(loop, lambda: self._joystick.get_trigger()) - def top(self, loop: Optional[EventLoop] = None) -> Trigger: + def top(self, loop: EventLoop | None = None) -> Trigger: """ Constructs an event instance around the top button's digital signal. diff --git a/subprojects/robotpy-commands-v2/commands2/button/commandlogitechf310controller.py b/subprojects/robotpy-commands-v2/commands2/button/commandlogitechf310controller.py index a4e74daf9..d6a4c15c4 100644 --- a/subprojects/robotpy-commands-v2/commands2/button/commandlogitechf310controller.py +++ b/subprojects/robotpy-commands-v2/commands2/button/commandlogitechf310controller.py @@ -1,7 +1,5 @@ # THIS FILE WAS AUTO-GENERATED BY ./commandsv2/generate_hids.py. DO NOT MODIFY -from typing import Optional, Union - from wpilib import EventLoop, LogitechF310Controller from .commandgenerichid import CommandGenericHID @@ -16,7 +14,7 @@ class CommandLogitechF310Controller: _hid: CommandGenericHID _controller: LogitechF310Controller - def __init__(self, hid: Union[int, LogitechF310Controller]): + def __init__(self, hid: int | LogitechF310Controller): """ Construct an instance of a controller. @@ -49,7 +47,7 @@ def get_controller(self) -> LogitechF310Controller: def button( self, button: LogitechF310Controller.Button, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs an event instance around this button's digital signal. @@ -59,7 +57,7 @@ def button( """ return self._hid.button(button.value, loop) - def a(self, loop: Optional[EventLoop] = None) -> Trigger: + def a(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the A button's digital signal. @@ -71,7 +69,7 @@ def a(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(LogitechF310Controller.Button.A, loop) - def b(self, loop: Optional[EventLoop] = None) -> Trigger: + def b(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the B button's digital signal. @@ -83,7 +81,7 @@ def b(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(LogitechF310Controller.Button.B, loop) - def x(self, loop: Optional[EventLoop] = None) -> Trigger: + def x(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the X button's digital signal. @@ -95,7 +93,7 @@ def x(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(LogitechF310Controller.Button.X, loop) - def y(self, loop: Optional[EventLoop] = None) -> Trigger: + def y(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Y button's digital signal. @@ -107,7 +105,7 @@ def y(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(LogitechF310Controller.Button.Y, loop) - def back(self, loop: Optional[EventLoop] = None) -> Trigger: + def back(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Back button's digital signal. @@ -119,7 +117,7 @@ def back(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(LogitechF310Controller.Button.BACK, loop) - def logitech(self, loop: Optional[EventLoop] = None) -> Trigger: + def logitech(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Logitech button's digital signal. @@ -131,7 +129,7 @@ def logitech(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(LogitechF310Controller.Button.LOGITECH, loop) - def start(self, loop: Optional[EventLoop] = None) -> Trigger: + def start(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Start button's digital signal. @@ -143,7 +141,7 @@ def start(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(LogitechF310Controller.Button.START, loop) - def left_stick(self, loop: Optional[EventLoop] = None) -> Trigger: + def left_stick(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Left Stick button's digital signal. @@ -155,7 +153,7 @@ def left_stick(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(LogitechF310Controller.Button.LEFT_STICK, loop) - def right_stick(self, loop: Optional[EventLoop] = None) -> Trigger: + def right_stick(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Right Stick button's digital signal. @@ -167,7 +165,7 @@ def right_stick(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(LogitechF310Controller.Button.RIGHT_STICK, loop) - def left_bumper(self, loop: Optional[EventLoop] = None) -> Trigger: + def left_bumper(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Left Bumper button's digital signal. @@ -179,7 +177,7 @@ def left_bumper(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(LogitechF310Controller.Button.LEFT_BUMPER, loop) - def right_bumper(self, loop: Optional[EventLoop] = None) -> Trigger: + def right_bumper(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Right Bumper button's digital signal. @@ -191,7 +189,7 @@ def right_bumper(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(LogitechF310Controller.Button.RIGHT_BUMPER, loop) - def dpad_up(self, loop: Optional[EventLoop] = None) -> Trigger: + def dpad_up(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Dpad Up button's digital signal. @@ -203,7 +201,7 @@ def dpad_up(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(LogitechF310Controller.Button.DPAD_UP, loop) - def dpad_down(self, loop: Optional[EventLoop] = None) -> Trigger: + def dpad_down(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Dpad Down button's digital signal. @@ -215,7 +213,7 @@ def dpad_down(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(LogitechF310Controller.Button.DPAD_DOWN, loop) - def dpad_left(self, loop: Optional[EventLoop] = None) -> Trigger: + def dpad_left(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Dpad Left button's digital signal. @@ -227,7 +225,7 @@ def dpad_left(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(LogitechF310Controller.Button.DPAD_LEFT, loop) - def dpad_right(self, loop: Optional[EventLoop] = None) -> Trigger: + def dpad_right(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Dpad Right button's digital signal. @@ -242,7 +240,7 @@ def dpad_right(self, loop: Optional[EventLoop] = None) -> Trigger: def left_trigger( self, threshold: float = 0.5, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs a Trigger instance around the Left Trigger axis value. The returned @@ -265,7 +263,7 @@ def left_trigger( def right_trigger( self, threshold: float = 0.5, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs a Trigger instance around the Right Trigger axis value. The returned @@ -289,7 +287,7 @@ def axis_less_than( self, axis: LogitechF310Controller.Axis, threshold: float, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs a Trigger instance that is true when the axis value is less than @@ -308,7 +306,7 @@ def axis_greater_than( self, axis: LogitechF310Controller.Axis, threshold: float, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs a Trigger instance that is true when the axis value is greater @@ -327,7 +325,7 @@ def axis_magnitude_greater_than( self, axis: LogitechF310Controller.Axis, threshold: float, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs a Trigger instance that is true when the axis magnitude is diff --git a/subprojects/robotpy-commands-v2/commands2/button/commandsteamcontroller.py b/subprojects/robotpy-commands-v2/commands2/button/commandsteamcontroller.py index 7016d13ed..efc107166 100644 --- a/subprojects/robotpy-commands-v2/commands2/button/commandsteamcontroller.py +++ b/subprojects/robotpy-commands-v2/commands2/button/commandsteamcontroller.py @@ -1,7 +1,5 @@ # THIS FILE WAS AUTO-GENERATED BY ./commandsv2/generate_hids.py. DO NOT MODIFY -from typing import Optional, Union - from wpilib import EventLoop, SteamController from .commandgenerichid import CommandGenericHID @@ -16,7 +14,7 @@ class CommandSteamController: _hid: CommandGenericHID _controller: SteamController - def __init__(self, hid: Union[int, SteamController]): + def __init__(self, hid: int | SteamController): """ Construct an instance of a controller. @@ -49,7 +47,7 @@ def get_controller(self) -> SteamController: def button( self, button: SteamController.Button, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs an event instance around this button's digital signal. @@ -59,7 +57,7 @@ def button( """ return self._hid.button(button.value, loop) - def a(self, loop: Optional[EventLoop] = None) -> Trigger: + def a(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the A button's digital signal. @@ -71,7 +69,7 @@ def a(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(SteamController.Button.A, loop) - def b(self, loop: Optional[EventLoop] = None) -> Trigger: + def b(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the B button's digital signal. @@ -83,7 +81,7 @@ def b(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(SteamController.Button.B, loop) - def x(self, loop: Optional[EventLoop] = None) -> Trigger: + def x(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the X button's digital signal. @@ -95,7 +93,7 @@ def x(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(SteamController.Button.X, loop) - def y(self, loop: Optional[EventLoop] = None) -> Trigger: + def y(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Y button's digital signal. @@ -107,7 +105,7 @@ def y(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(SteamController.Button.Y, loop) - def menu(self, loop: Optional[EventLoop] = None) -> Trigger: + def menu(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Menu button's digital signal. @@ -119,7 +117,7 @@ def menu(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(SteamController.Button.MENU, loop) - def steam(self, loop: Optional[EventLoop] = None) -> Trigger: + def steam(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Steam button's digital signal. @@ -131,7 +129,7 @@ def steam(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(SteamController.Button.STEAM, loop) - def view(self, loop: Optional[EventLoop] = None) -> Trigger: + def view(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the View button's digital signal. @@ -143,7 +141,7 @@ def view(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(SteamController.Button.VIEW, loop) - def left_stick(self, loop: Optional[EventLoop] = None) -> Trigger: + def left_stick(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Left Stick button's digital signal. @@ -155,7 +153,7 @@ def left_stick(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(SteamController.Button.LEFT_STICK, loop) - def right_stick(self, loop: Optional[EventLoop] = None) -> Trigger: + def right_stick(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Right Stick button's digital signal. @@ -167,7 +165,7 @@ def right_stick(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(SteamController.Button.RIGHT_STICK, loop) - def left_bumper(self, loop: Optional[EventLoop] = None) -> Trigger: + def left_bumper(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Left Bumper button's digital signal. @@ -179,7 +177,7 @@ def left_bumper(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(SteamController.Button.LEFT_BUMPER, loop) - def right_bumper(self, loop: Optional[EventLoop] = None) -> Trigger: + def right_bumper(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Right Bumper button's digital signal. @@ -191,7 +189,7 @@ def right_bumper(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(SteamController.Button.RIGHT_BUMPER, loop) - def dpad_up(self, loop: Optional[EventLoop] = None) -> Trigger: + def dpad_up(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Dpad Up button's digital signal. @@ -203,7 +201,7 @@ def dpad_up(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(SteamController.Button.DPAD_UP, loop) - def dpad_down(self, loop: Optional[EventLoop] = None) -> Trigger: + def dpad_down(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Dpad Down button's digital signal. @@ -215,7 +213,7 @@ def dpad_down(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(SteamController.Button.DPAD_DOWN, loop) - def dpad_left(self, loop: Optional[EventLoop] = None) -> Trigger: + def dpad_left(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Dpad Left button's digital signal. @@ -227,7 +225,7 @@ def dpad_left(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(SteamController.Button.DPAD_LEFT, loop) - def dpad_right(self, loop: Optional[EventLoop] = None) -> Trigger: + def dpad_right(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Dpad Right button's digital signal. @@ -239,7 +237,7 @@ def dpad_right(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(SteamController.Button.DPAD_RIGHT, loop) - def qam(self, loop: Optional[EventLoop] = None) -> Trigger: + def qam(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the QAM button's digital signal. @@ -251,7 +249,7 @@ def qam(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(SteamController.Button.QAM, loop) - def right_paddle1(self, loop: Optional[EventLoop] = None) -> Trigger: + def right_paddle1(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Right Paddle 1 button's digital signal. @@ -263,7 +261,7 @@ def right_paddle1(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(SteamController.Button.RIGHT_PADDLE_1, loop) - def left_paddle1(self, loop: Optional[EventLoop] = None) -> Trigger: + def left_paddle1(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Left Paddle 1 button's digital signal. @@ -275,7 +273,7 @@ def left_paddle1(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(SteamController.Button.LEFT_PADDLE_1, loop) - def right_paddle2(self, loop: Optional[EventLoop] = None) -> Trigger: + def right_paddle2(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Right Paddle 2 button's digital signal. @@ -287,7 +285,7 @@ def right_paddle2(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(SteamController.Button.RIGHT_PADDLE_2, loop) - def left_paddle2(self, loop: Optional[EventLoop] = None) -> Trigger: + def left_paddle2(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Left Paddle 2 button's digital signal. @@ -299,7 +297,7 @@ def left_paddle2(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(SteamController.Button.LEFT_PADDLE_2, loop) - def left_touchpad(self, loop: Optional[EventLoop] = None) -> Trigger: + def left_touchpad(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Left Touchpad button's digital signal. @@ -311,7 +309,7 @@ def left_touchpad(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(SteamController.Button.LEFT_TOUCHPAD, loop) - def right_touchpad(self, loop: Optional[EventLoop] = None) -> Trigger: + def right_touchpad(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Right Touchpad button's digital signal. @@ -323,7 +321,7 @@ def right_touchpad(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(SteamController.Button.RIGHT_TOUCHPAD, loop) - def left_stick_touch(self, loop: Optional[EventLoop] = None) -> Trigger: + def left_stick_touch(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Left Stick Touch button's digital signal. @@ -335,7 +333,7 @@ def left_stick_touch(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(SteamController.Button.LEFT_STICK_TOUCH, loop) - def right_stick_touch(self, loop: Optional[EventLoop] = None) -> Trigger: + def right_stick_touch(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Right Stick Touch button's digital signal. @@ -347,7 +345,7 @@ def right_stick_touch(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(SteamController.Button.RIGHT_STICK_TOUCH, loop) - def left_grip_touch(self, loop: Optional[EventLoop] = None) -> Trigger: + def left_grip_touch(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Left Grip Touch button's digital signal. @@ -359,7 +357,7 @@ def left_grip_touch(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(SteamController.Button.LEFT_GRIP_TOUCH, loop) - def right_grip_touch(self, loop: Optional[EventLoop] = None) -> Trigger: + def right_grip_touch(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Right Grip Touch button's digital signal. @@ -374,7 +372,7 @@ def right_grip_touch(self, loop: Optional[EventLoop] = None) -> Trigger: def left_trigger( self, threshold: float = 0.5, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs a Trigger instance around the Left Trigger axis value. The returned @@ -397,7 +395,7 @@ def left_trigger( def right_trigger( self, threshold: float = 0.5, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs a Trigger instance around the Right Trigger axis value. The returned @@ -421,7 +419,7 @@ def axis_less_than( self, axis: SteamController.Axis, threshold: float, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs a Trigger instance that is true when the axis value is less than @@ -440,7 +438,7 @@ def axis_greater_than( self, axis: SteamController.Axis, threshold: float, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs a Trigger instance that is true when the axis value is greater @@ -459,7 +457,7 @@ def axis_magnitude_greater_than( self, axis: SteamController.Axis, threshold: float, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs a Trigger instance that is true when the axis magnitude is diff --git a/subprojects/robotpy-commands-v2/commands2/button/commandswitch2gccontroller.py b/subprojects/robotpy-commands-v2/commands2/button/commandswitch2gccontroller.py index c93daab22..ef28bc184 100644 --- a/subprojects/robotpy-commands-v2/commands2/button/commandswitch2gccontroller.py +++ b/subprojects/robotpy-commands-v2/commands2/button/commandswitch2gccontroller.py @@ -1,7 +1,5 @@ # THIS FILE WAS AUTO-GENERATED BY ./commandsv2/generate_hids.py. DO NOT MODIFY -from typing import Optional, Union - from wpilib import EventLoop, Switch2GCController from .commandgenerichid import CommandGenericHID @@ -16,7 +14,7 @@ class CommandSwitch2GCController: _hid: CommandGenericHID _controller: Switch2GCController - def __init__(self, hid: Union[int, Switch2GCController]): + def __init__(self, hid: int | Switch2GCController): """ Construct an instance of a controller. @@ -49,7 +47,7 @@ def get_controller(self) -> Switch2GCController: def button( self, button: Switch2GCController.Button, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs an event instance around this button's digital signal. @@ -59,7 +57,7 @@ def button( """ return self._hid.button(button.value, loop) - def a(self, loop: Optional[EventLoop] = None) -> Trigger: + def a(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the A button's digital signal. @@ -71,7 +69,7 @@ def a(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(Switch2GCController.Button.A, loop) - def x(self, loop: Optional[EventLoop] = None) -> Trigger: + def x(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the X button's digital signal. @@ -83,7 +81,7 @@ def x(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(Switch2GCController.Button.X, loop) - def b(self, loop: Optional[EventLoop] = None) -> Trigger: + def b(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the B button's digital signal. @@ -95,7 +93,7 @@ def b(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(Switch2GCController.Button.B, loop) - def y(self, loop: Optional[EventLoop] = None) -> Trigger: + def y(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Y button's digital signal. @@ -107,7 +105,7 @@ def y(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(Switch2GCController.Button.Y, loop) - def home(self, loop: Optional[EventLoop] = None) -> Trigger: + def home(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Home button's digital signal. @@ -119,7 +117,7 @@ def home(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(Switch2GCController.Button.HOME, loop) - def start(self, loop: Optional[EventLoop] = None) -> Trigger: + def start(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Start button's digital signal. @@ -131,7 +129,7 @@ def start(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(Switch2GCController.Button.START, loop) - def zl(self, loop: Optional[EventLoop] = None) -> Trigger: + def zl(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the ZL button's digital signal. @@ -143,7 +141,7 @@ def zl(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(Switch2GCController.Button.ZL, loop) - def z(self, loop: Optional[EventLoop] = None) -> Trigger: + def z(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Z button's digital signal. @@ -155,7 +153,7 @@ def z(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(Switch2GCController.Button.Z, loop) - def dpad_up(self, loop: Optional[EventLoop] = None) -> Trigger: + def dpad_up(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Dpad Up button's digital signal. @@ -167,7 +165,7 @@ def dpad_up(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(Switch2GCController.Button.DPAD_UP, loop) - def dpad_down(self, loop: Optional[EventLoop] = None) -> Trigger: + def dpad_down(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Dpad Down button's digital signal. @@ -179,7 +177,7 @@ def dpad_down(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(Switch2GCController.Button.DPAD_DOWN, loop) - def dpad_left(self, loop: Optional[EventLoop] = None) -> Trigger: + def dpad_left(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Dpad Left button's digital signal. @@ -191,7 +189,7 @@ def dpad_left(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(Switch2GCController.Button.DPAD_LEFT, loop) - def dpad_right(self, loop: Optional[EventLoop] = None) -> Trigger: + def dpad_right(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Dpad Right button's digital signal. @@ -203,7 +201,7 @@ def dpad_right(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(Switch2GCController.Button.DPAD_RIGHT, loop) - def capture(self, loop: Optional[EventLoop] = None) -> Trigger: + def capture(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Capture button's digital signal. @@ -215,7 +213,7 @@ def capture(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(Switch2GCController.Button.CAPTURE, loop) - def c(self, loop: Optional[EventLoop] = None) -> Trigger: + def c(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the C button's digital signal. @@ -227,7 +225,7 @@ def c(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(Switch2GCController.Button.C, loop) - def l(self, loop: Optional[EventLoop] = None) -> Trigger: + def l(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the L button's digital signal. @@ -239,7 +237,7 @@ def l(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(Switch2GCController.Button.L, loop) - def r(self, loop: Optional[EventLoop] = None) -> Trigger: + def r(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the R button's digital signal. @@ -254,7 +252,7 @@ def r(self, loop: Optional[EventLoop] = None) -> Trigger: def l_trigger( self, threshold: float = 0.5, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs a Trigger instance around the L Trigger axis value. The returned @@ -277,7 +275,7 @@ def l_trigger( def r_trigger( self, threshold: float = 0.5, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs a Trigger instance around the R Trigger axis value. The returned @@ -301,7 +299,7 @@ def axis_less_than( self, axis: Switch2GCController.Axis, threshold: float, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs a Trigger instance that is true when the axis value is less than @@ -320,7 +318,7 @@ def axis_greater_than( self, axis: Switch2GCController.Axis, threshold: float, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs a Trigger instance that is true when the axis value is greater @@ -339,7 +337,7 @@ def axis_magnitude_greater_than( self, axis: Switch2GCController.Axis, threshold: float, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs a Trigger instance that is true when the axis magnitude is diff --git a/subprojects/robotpy-commands-v2/commands2/button/commandswitch2procontroller.py b/subprojects/robotpy-commands-v2/commands2/button/commandswitch2procontroller.py index 7288370b9..57eb783ff 100644 --- a/subprojects/robotpy-commands-v2/commands2/button/commandswitch2procontroller.py +++ b/subprojects/robotpy-commands-v2/commands2/button/commandswitch2procontroller.py @@ -1,7 +1,5 @@ # THIS FILE WAS AUTO-GENERATED BY ./commandsv2/generate_hids.py. DO NOT MODIFY -from typing import Optional, Union - from wpilib import EventLoop, Switch2ProController from .commandgenerichid import CommandGenericHID @@ -16,7 +14,7 @@ class CommandSwitch2ProController: _hid: CommandGenericHID _controller: Switch2ProController - def __init__(self, hid: Union[int, Switch2ProController]): + def __init__(self, hid: int | Switch2ProController): """ Construct an instance of a controller. @@ -49,7 +47,7 @@ def get_controller(self) -> Switch2ProController: def button( self, button: Switch2ProController.Button, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs an event instance around this button's digital signal. @@ -59,7 +57,7 @@ def button( """ return self._hid.button(button.value, loop) - def b(self, loop: Optional[EventLoop] = None) -> Trigger: + def b(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the B button's digital signal. @@ -71,7 +69,7 @@ def b(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(Switch2ProController.Button.B, loop) - def a(self, loop: Optional[EventLoop] = None) -> Trigger: + def a(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the A button's digital signal. @@ -83,7 +81,7 @@ def a(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(Switch2ProController.Button.A, loop) - def y(self, loop: Optional[EventLoop] = None) -> Trigger: + def y(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Y button's digital signal. @@ -95,7 +93,7 @@ def y(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(Switch2ProController.Button.Y, loop) - def x(self, loop: Optional[EventLoop] = None) -> Trigger: + def x(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the X button's digital signal. @@ -107,7 +105,7 @@ def x(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(Switch2ProController.Button.X, loop) - def minus(self, loop: Optional[EventLoop] = None) -> Trigger: + def minus(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Minus button's digital signal. @@ -119,7 +117,7 @@ def minus(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(Switch2ProController.Button.MINUS, loop) - def home(self, loop: Optional[EventLoop] = None) -> Trigger: + def home(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Home button's digital signal. @@ -131,7 +129,7 @@ def home(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(Switch2ProController.Button.HOME, loop) - def plus(self, loop: Optional[EventLoop] = None) -> Trigger: + def plus(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Plus button's digital signal. @@ -143,7 +141,7 @@ def plus(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(Switch2ProController.Button.PLUS, loop) - def left_stick(self, loop: Optional[EventLoop] = None) -> Trigger: + def left_stick(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Left Stick button's digital signal. @@ -155,7 +153,7 @@ def left_stick(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(Switch2ProController.Button.LEFT_STICK, loop) - def right_stick(self, loop: Optional[EventLoop] = None) -> Trigger: + def right_stick(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Right Stick button's digital signal. @@ -167,7 +165,7 @@ def right_stick(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(Switch2ProController.Button.RIGHT_STICK, loop) - def l(self, loop: Optional[EventLoop] = None) -> Trigger: + def l(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the L button's digital signal. @@ -179,7 +177,7 @@ def l(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(Switch2ProController.Button.L, loop) - def r(self, loop: Optional[EventLoop] = None) -> Trigger: + def r(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the R button's digital signal. @@ -191,7 +189,7 @@ def r(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(Switch2ProController.Button.R, loop) - def dpad_up(self, loop: Optional[EventLoop] = None) -> Trigger: + def dpad_up(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Dpad Up button's digital signal. @@ -203,7 +201,7 @@ def dpad_up(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(Switch2ProController.Button.DPAD_UP, loop) - def dpad_down(self, loop: Optional[EventLoop] = None) -> Trigger: + def dpad_down(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Dpad Down button's digital signal. @@ -215,7 +213,7 @@ def dpad_down(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(Switch2ProController.Button.DPAD_DOWN, loop) - def dpad_left(self, loop: Optional[EventLoop] = None) -> Trigger: + def dpad_left(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Dpad Left button's digital signal. @@ -227,7 +225,7 @@ def dpad_left(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(Switch2ProController.Button.DPAD_LEFT, loop) - def dpad_right(self, loop: Optional[EventLoop] = None) -> Trigger: + def dpad_right(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Dpad Right button's digital signal. @@ -239,7 +237,7 @@ def dpad_right(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(Switch2ProController.Button.DPAD_RIGHT, loop) - def capture(self, loop: Optional[EventLoop] = None) -> Trigger: + def capture(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Capture button's digital signal. @@ -251,7 +249,7 @@ def capture(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(Switch2ProController.Button.CAPTURE, loop) - def gr(self, loop: Optional[EventLoop] = None) -> Trigger: + def gr(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the GR button's digital signal. @@ -263,7 +261,7 @@ def gr(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(Switch2ProController.Button.GR, loop) - def gl(self, loop: Optional[EventLoop] = None) -> Trigger: + def gl(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the GL button's digital signal. @@ -275,7 +273,7 @@ def gl(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(Switch2ProController.Button.GL, loop) - def c(self, loop: Optional[EventLoop] = None) -> Trigger: + def c(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the C button's digital signal. @@ -290,7 +288,7 @@ def c(self, loop: Optional[EventLoop] = None) -> Trigger: def zl( self, threshold: float = 0.5, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs a Trigger instance around the ZL axis value. The returned @@ -313,7 +311,7 @@ def zl( def zr( self, threshold: float = 0.5, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs a Trigger instance around the ZR axis value. The returned @@ -337,7 +335,7 @@ def axis_less_than( self, axis: Switch2ProController.Axis, threshold: float, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs a Trigger instance that is true when the axis value is less than @@ -356,7 +354,7 @@ def axis_greater_than( self, axis: Switch2ProController.Axis, threshold: float, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs a Trigger instance that is true when the axis value is greater @@ -375,7 +373,7 @@ def axis_magnitude_greater_than( self, axis: Switch2ProController.Axis, threshold: float, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs a Trigger instance that is true when the axis magnitude is diff --git a/subprojects/robotpy-commands-v2/commands2/button/commandswitchn64controller.py b/subprojects/robotpy-commands-v2/commands2/button/commandswitchn64controller.py index 997631db3..9a0c01738 100644 --- a/subprojects/robotpy-commands-v2/commands2/button/commandswitchn64controller.py +++ b/subprojects/robotpy-commands-v2/commands2/button/commandswitchn64controller.py @@ -1,7 +1,5 @@ # THIS FILE WAS AUTO-GENERATED BY ./commandsv2/generate_hids.py. DO NOT MODIFY -from typing import Optional, Union - from wpilib import EventLoop, SwitchN64Controller from .commandgenerichid import CommandGenericHID @@ -16,7 +14,7 @@ class CommandSwitchN64Controller: _hid: CommandGenericHID _controller: SwitchN64Controller - def __init__(self, hid: Union[int, SwitchN64Controller]): + def __init__(self, hid: int | SwitchN64Controller): """ Construct an instance of a controller. @@ -49,7 +47,7 @@ def get_controller(self) -> SwitchN64Controller: def button( self, button: SwitchN64Controller.Button, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs an event instance around this button's digital signal. @@ -59,7 +57,7 @@ def button( """ return self._hid.button(button.value, loop) - def a(self, loop: Optional[EventLoop] = None) -> Trigger: + def a(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the A button's digital signal. @@ -71,7 +69,7 @@ def a(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(SwitchN64Controller.Button.A, loop) - def b(self, loop: Optional[EventLoop] = None) -> Trigger: + def b(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the B button's digital signal. @@ -83,7 +81,7 @@ def b(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(SwitchN64Controller.Button.B, loop) - def c_left(self, loop: Optional[EventLoop] = None) -> Trigger: + def c_left(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the C Left button's digital signal. @@ -95,7 +93,7 @@ def c_left(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(SwitchN64Controller.Button.C_LEFT, loop) - def c_up(self, loop: Optional[EventLoop] = None) -> Trigger: + def c_up(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the C Up button's digital signal. @@ -107,7 +105,7 @@ def c_up(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(SwitchN64Controller.Button.C_UP, loop) - def capture(self, loop: Optional[EventLoop] = None) -> Trigger: + def capture(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Capture button's digital signal. @@ -119,7 +117,7 @@ def capture(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(SwitchN64Controller.Button.CAPTURE, loop) - def home(self, loop: Optional[EventLoop] = None) -> Trigger: + def home(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Home button's digital signal. @@ -131,7 +129,7 @@ def home(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(SwitchN64Controller.Button.HOME, loop) - def start(self, loop: Optional[EventLoop] = None) -> Trigger: + def start(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Start button's digital signal. @@ -143,7 +141,7 @@ def start(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(SwitchN64Controller.Button.START, loop) - def c_down(self, loop: Optional[EventLoop] = None) -> Trigger: + def c_down(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the C Down button's digital signal. @@ -155,7 +153,7 @@ def c_down(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(SwitchN64Controller.Button.C_DOWN, loop) - def l(self, loop: Optional[EventLoop] = None) -> Trigger: + def l(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the L button's digital signal. @@ -167,7 +165,7 @@ def l(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(SwitchN64Controller.Button.L, loop) - def r(self, loop: Optional[EventLoop] = None) -> Trigger: + def r(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the R button's digital signal. @@ -179,7 +177,7 @@ def r(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(SwitchN64Controller.Button.R, loop) - def dpad_up(self, loop: Optional[EventLoop] = None) -> Trigger: + def dpad_up(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Dpad Up button's digital signal. @@ -191,7 +189,7 @@ def dpad_up(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(SwitchN64Controller.Button.DPAD_UP, loop) - def dpad_down(self, loop: Optional[EventLoop] = None) -> Trigger: + def dpad_down(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Dpad Down button's digital signal. @@ -203,7 +201,7 @@ def dpad_down(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(SwitchN64Controller.Button.DPAD_DOWN, loop) - def dpad_left(self, loop: Optional[EventLoop] = None) -> Trigger: + def dpad_left(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Dpad Left button's digital signal. @@ -215,7 +213,7 @@ def dpad_left(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(SwitchN64Controller.Button.DPAD_LEFT, loop) - def dpad_right(self, loop: Optional[EventLoop] = None) -> Trigger: + def dpad_right(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Dpad Right button's digital signal. @@ -227,7 +225,7 @@ def dpad_right(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(SwitchN64Controller.Button.DPAD_RIGHT, loop) - def c_right(self, loop: Optional[EventLoop] = None) -> Trigger: + def c_right(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the C Right button's digital signal. @@ -242,7 +240,7 @@ def c_right(self, loop: Optional[EventLoop] = None) -> Trigger: def zr( self, threshold: float = 0.5, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs a Trigger instance around the ZR axis value. The returned @@ -266,7 +264,7 @@ def axis_less_than( self, axis: SwitchN64Controller.Axis, threshold: float, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs a Trigger instance that is true when the axis value is less than @@ -285,7 +283,7 @@ def axis_greater_than( self, axis: SwitchN64Controller.Axis, threshold: float, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs a Trigger instance that is true when the axis value is greater @@ -304,7 +302,7 @@ def axis_magnitude_greater_than( self, axis: SwitchN64Controller.Axis, threshold: float, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs a Trigger instance that is true when the axis magnitude is diff --git a/subprojects/robotpy-commands-v2/commands2/button/commandswitchprocontroller.py b/subprojects/robotpy-commands-v2/commands2/button/commandswitchprocontroller.py index 1fa45dbb5..d28f8b8e5 100644 --- a/subprojects/robotpy-commands-v2/commands2/button/commandswitchprocontroller.py +++ b/subprojects/robotpy-commands-v2/commands2/button/commandswitchprocontroller.py @@ -1,7 +1,5 @@ # THIS FILE WAS AUTO-GENERATED BY ./commandsv2/generate_hids.py. DO NOT MODIFY -from typing import Optional, Union - from wpilib import EventLoop, SwitchProController from .commandgenerichid import CommandGenericHID @@ -16,7 +14,7 @@ class CommandSwitchProController: _hid: CommandGenericHID _controller: SwitchProController - def __init__(self, hid: Union[int, SwitchProController]): + def __init__(self, hid: int | SwitchProController): """ Construct an instance of a controller. @@ -49,7 +47,7 @@ def get_controller(self) -> SwitchProController: def button( self, button: SwitchProController.Button, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs an event instance around this button's digital signal. @@ -59,7 +57,7 @@ def button( """ return self._hid.button(button.value, loop) - def b(self, loop: Optional[EventLoop] = None) -> Trigger: + def b(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the B button's digital signal. @@ -71,7 +69,7 @@ def b(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(SwitchProController.Button.B, loop) - def a(self, loop: Optional[EventLoop] = None) -> Trigger: + def a(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the A button's digital signal. @@ -83,7 +81,7 @@ def a(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(SwitchProController.Button.A, loop) - def y(self, loop: Optional[EventLoop] = None) -> Trigger: + def y(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Y button's digital signal. @@ -95,7 +93,7 @@ def y(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(SwitchProController.Button.Y, loop) - def x(self, loop: Optional[EventLoop] = None) -> Trigger: + def x(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the X button's digital signal. @@ -107,7 +105,7 @@ def x(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(SwitchProController.Button.X, loop) - def minus(self, loop: Optional[EventLoop] = None) -> Trigger: + def minus(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Minus button's digital signal. @@ -119,7 +117,7 @@ def minus(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(SwitchProController.Button.MINUS, loop) - def home(self, loop: Optional[EventLoop] = None) -> Trigger: + def home(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Home button's digital signal. @@ -131,7 +129,7 @@ def home(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(SwitchProController.Button.HOME, loop) - def plus(self, loop: Optional[EventLoop] = None) -> Trigger: + def plus(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Plus button's digital signal. @@ -143,7 +141,7 @@ def plus(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(SwitchProController.Button.PLUS, loop) - def left_stick(self, loop: Optional[EventLoop] = None) -> Trigger: + def left_stick(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Left Stick button's digital signal. @@ -155,7 +153,7 @@ def left_stick(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(SwitchProController.Button.LEFT_STICK, loop) - def right_stick(self, loop: Optional[EventLoop] = None) -> Trigger: + def right_stick(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Right Stick button's digital signal. @@ -167,7 +165,7 @@ def right_stick(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(SwitchProController.Button.RIGHT_STICK, loop) - def l(self, loop: Optional[EventLoop] = None) -> Trigger: + def l(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the L button's digital signal. @@ -179,7 +177,7 @@ def l(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(SwitchProController.Button.L, loop) - def r(self, loop: Optional[EventLoop] = None) -> Trigger: + def r(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the R button's digital signal. @@ -191,7 +189,7 @@ def r(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(SwitchProController.Button.R, loop) - def dpad_up(self, loop: Optional[EventLoop] = None) -> Trigger: + def dpad_up(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Dpad Up button's digital signal. @@ -203,7 +201,7 @@ def dpad_up(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(SwitchProController.Button.DPAD_UP, loop) - def dpad_down(self, loop: Optional[EventLoop] = None) -> Trigger: + def dpad_down(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Dpad Down button's digital signal. @@ -215,7 +213,7 @@ def dpad_down(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(SwitchProController.Button.DPAD_DOWN, loop) - def dpad_left(self, loop: Optional[EventLoop] = None) -> Trigger: + def dpad_left(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Dpad Left button's digital signal. @@ -227,7 +225,7 @@ def dpad_left(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(SwitchProController.Button.DPAD_LEFT, loop) - def dpad_right(self, loop: Optional[EventLoop] = None) -> Trigger: + def dpad_right(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Dpad Right button's digital signal. @@ -239,7 +237,7 @@ def dpad_right(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(SwitchProController.Button.DPAD_RIGHT, loop) - def capture(self, loop: Optional[EventLoop] = None) -> Trigger: + def capture(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Capture button's digital signal. @@ -254,7 +252,7 @@ def capture(self, loop: Optional[EventLoop] = None) -> Trigger: def zl( self, threshold: float = 0.5, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs a Trigger instance around the ZL axis value. The returned @@ -277,7 +275,7 @@ def zl( def zr( self, threshold: float = 0.5, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs a Trigger instance around the ZR axis value. The returned @@ -301,7 +299,7 @@ def axis_less_than( self, axis: SwitchProController.Axis, threshold: float, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs a Trigger instance that is true when the axis value is less than @@ -320,7 +318,7 @@ def axis_greater_than( self, axis: SwitchProController.Axis, threshold: float, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs a Trigger instance that is true when the axis value is greater @@ -339,7 +337,7 @@ def axis_magnitude_greater_than( self, axis: SwitchProController.Axis, threshold: float, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs a Trigger instance that is true when the axis magnitude is diff --git a/subprojects/robotpy-commands-v2/commands2/button/commandxboxcontroller.py b/subprojects/robotpy-commands-v2/commands2/button/commandxboxcontroller.py index 1a06fdb21..eb2afd2f4 100644 --- a/subprojects/robotpy-commands-v2/commands2/button/commandxboxcontroller.py +++ b/subprojects/robotpy-commands-v2/commands2/button/commandxboxcontroller.py @@ -1,7 +1,5 @@ # THIS FILE WAS AUTO-GENERATED BY ./commandsv2/generate_hids.py. DO NOT MODIFY -from typing import Optional, Union - from wpilib import EventLoop, XboxController from .commandgenerichid import CommandGenericHID @@ -16,7 +14,7 @@ class CommandXboxController: _hid: CommandGenericHID _controller: XboxController - def __init__(self, hid: Union[int, XboxController]): + def __init__(self, hid: int | XboxController): """ Construct an instance of a controller. @@ -49,7 +47,7 @@ def get_controller(self) -> XboxController: def button( self, button: XboxController.Button, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs an event instance around this button's digital signal. @@ -59,7 +57,7 @@ def button( """ return self._hid.button(button.value, loop) - def a(self, loop: Optional[EventLoop] = None) -> Trigger: + def a(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the A button's digital signal. @@ -71,7 +69,7 @@ def a(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(XboxController.Button.A, loop) - def b(self, loop: Optional[EventLoop] = None) -> Trigger: + def b(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the B button's digital signal. @@ -83,7 +81,7 @@ def b(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(XboxController.Button.B, loop) - def x(self, loop: Optional[EventLoop] = None) -> Trigger: + def x(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the X button's digital signal. @@ -95,7 +93,7 @@ def x(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(XboxController.Button.X, loop) - def y(self, loop: Optional[EventLoop] = None) -> Trigger: + def y(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Y button's digital signal. @@ -107,7 +105,7 @@ def y(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(XboxController.Button.Y, loop) - def view(self, loop: Optional[EventLoop] = None) -> Trigger: + def view(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the View button's digital signal. @@ -119,7 +117,7 @@ def view(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(XboxController.Button.VIEW, loop) - def xbox(self, loop: Optional[EventLoop] = None) -> Trigger: + def xbox(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Xbox button's digital signal. @@ -131,7 +129,7 @@ def xbox(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(XboxController.Button.XBOX, loop) - def menu(self, loop: Optional[EventLoop] = None) -> Trigger: + def menu(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Menu button's digital signal. @@ -143,7 +141,7 @@ def menu(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(XboxController.Button.MENU, loop) - def left_stick(self, loop: Optional[EventLoop] = None) -> Trigger: + def left_stick(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Left Stick button's digital signal. @@ -155,7 +153,7 @@ def left_stick(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(XboxController.Button.LEFT_STICK, loop) - def right_stick(self, loop: Optional[EventLoop] = None) -> Trigger: + def right_stick(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Right Stick button's digital signal. @@ -167,7 +165,7 @@ def right_stick(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(XboxController.Button.RIGHT_STICK, loop) - def left_bumper(self, loop: Optional[EventLoop] = None) -> Trigger: + def left_bumper(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Left Bumper button's digital signal. @@ -179,7 +177,7 @@ def left_bumper(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(XboxController.Button.LEFT_BUMPER, loop) - def right_bumper(self, loop: Optional[EventLoop] = None) -> Trigger: + def right_bumper(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Right Bumper button's digital signal. @@ -191,7 +189,7 @@ def right_bumper(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(XboxController.Button.RIGHT_BUMPER, loop) - def dpad_up(self, loop: Optional[EventLoop] = None) -> Trigger: + def dpad_up(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Dpad Up button's digital signal. @@ -203,7 +201,7 @@ def dpad_up(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(XboxController.Button.DPAD_UP, loop) - def dpad_down(self, loop: Optional[EventLoop] = None) -> Trigger: + def dpad_down(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Dpad Down button's digital signal. @@ -215,7 +213,7 @@ def dpad_down(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(XboxController.Button.DPAD_DOWN, loop) - def dpad_left(self, loop: Optional[EventLoop] = None) -> Trigger: + def dpad_left(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Dpad Left button's digital signal. @@ -227,7 +225,7 @@ def dpad_left(self, loop: Optional[EventLoop] = None) -> Trigger: """ return self.button(XboxController.Button.DPAD_LEFT, loop) - def dpad_right(self, loop: Optional[EventLoop] = None) -> Trigger: + def dpad_right(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the Dpad Right button's digital signal. @@ -242,7 +240,7 @@ def dpad_right(self, loop: Optional[EventLoop] = None) -> Trigger: def left_trigger( self, threshold: float = 0.5, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs a Trigger instance around the Left Trigger axis value. The returned @@ -265,7 +263,7 @@ def left_trigger( def right_trigger( self, threshold: float = 0.5, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs a Trigger instance around the Right Trigger axis value. The returned @@ -289,7 +287,7 @@ def axis_less_than( self, axis: XboxController.Axis, threshold: float, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs a Trigger instance that is true when the axis value is less than @@ -308,7 +306,7 @@ def axis_greater_than( self, axis: XboxController.Axis, threshold: float, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs a Trigger instance that is true when the axis value is greater @@ -327,7 +325,7 @@ def axis_magnitude_greater_than( self, axis: XboxController.Axis, threshold: float, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs a Trigger instance that is true when the axis magnitude is diff --git a/subprojects/robotpy-commands-v2/commands2/button/trigger.py b/subprojects/robotpy-commands-v2/commands2/button/trigger.py index 1013e3a89..5b969e8d3 100644 --- a/subprojects/robotpy-commands-v2/commands2/button/trigger.py +++ b/subprojects/robotpy-commands-v2/commands2/button/trigger.py @@ -1,8 +1,8 @@ # validated: 2024-04-02 DS 0b1345946950 button/Trigger.java +from collections.abc import Callable from types import SimpleNamespace -from typing import Callable, overload +from typing import Self, overload -from typing_extensions import Self from wpilib import EventLoop from wpimath import Debouncer diff --git a/subprojects/robotpy-commands-v2/commands2/cmd.py b/subprojects/robotpy-commands-v2/commands2/cmd.py index 7622f7d4e..40adb98d9 100644 --- a/subprojects/robotpy-commands-v2/commands2/cmd.py +++ b/subprojects/robotpy-commands-v2/commands2/cmd.py @@ -1,5 +1,6 @@ # validated: 2024-01-20 DS 8aeee0362672 Commands.java -from typing import Any, Callable, Dict, Hashable +from collections.abc import Callable, Hashable +from typing import Any from wpimath import units @@ -156,7 +157,7 @@ def either( def select( - commands: Dict[Hashable, Command], selector: Callable[[], Hashable] + commands: dict[Hashable, Command], selector: Callable[[], Hashable] ) -> Command: """ Runs one of several commands, based on the selector function. diff --git a/subprojects/robotpy-commands-v2/commands2/command.py b/subprojects/robotpy-commands-v2/commands2/command.py index 2f0117d1a..d0585e13d 100644 --- a/subprojects/robotpy-commands-v2/commands2/command.py +++ b/subprojects/robotpy-commands-v2/commands2/command.py @@ -4,13 +4,11 @@ from __future__ import annotations +from collections.abc import Callable from enum import Enum -from typing import TYPE_CHECKING, Any, Callable, Set, Union - -from typing_extensions import Self, TypeAlias +from typing import TYPE_CHECKING, Any, Self, TypeAlias if TYPE_CHECKING: - from .instantcommand import InstantCommand from .subsystem import Subsystem from .parallelracegroup import ParallelRaceGroup from .sequentialcommandgroup import SequentialCommandGroup @@ -57,7 +55,7 @@ class Command(TelemetryLoggable, ComplexTunable): InterruptionBehavior # type alias for 2023 location ) - requirements: Set[Subsystem] + requirements: set[Subsystem] def __new__(cls, *args, **kwargs) -> Self: instance = super().__new__( @@ -98,7 +96,7 @@ def is_finished(self) -> bool: """ return False - def get_requirements(self) -> Set[Subsystem]: + def get_requirements(self) -> set[Subsystem]: """ Specifies the set of subsystems used by this command. Two commands cannot use the same subsystem at the same time. If another command is scheduled that shares a requirement, :meth:`.get_interruption_behavior` will be checked and followed. If no subsystems are required, return @@ -200,7 +198,7 @@ def only_while(self, condition: Callable[[], bool]) -> ParallelRaceGroup: return self.until(lambda: not condition()) def before_starting( - self, before: Union[Command, Callable[[], None]] + self, before: Command | Callable[[], None] ) -> SequentialCommandGroup: """ Decorates this command with a callable or command to run before this command starts. diff --git a/subprojects/robotpy-commands-v2/commands2/commandscheduler.py b/subprojects/robotpy-commands-v2/commands2/commandscheduler.py index 0cb17f1e3..2ab8f02af 100644 --- a/subprojects/robotpy-commands-v2/commands2/commandscheduler.py +++ b/subprojects/robotpy-commands-v2/commands2/commandscheduler.py @@ -4,10 +4,10 @@ import inspect import os.path import traceback -from typing import Any, Callable, Dict, Iterable, List, Optional, Set, Union +from collections.abc import Callable, Iterable +from typing import Any from telemetry import TelemetryLoggable, TelemetryTable -from typing_extensions import Self from tunables import ComplexTunable, Tunable, TunableRegistry, TunableTable import wpiutil from wpilib import ( @@ -34,7 +34,7 @@ class CommandScheduler(TelemetryLoggable, ComplexTunable): methods to be called and for their default commands to be scheduled. """ - _instance: Optional[CommandScheduler] = None + _instance: CommandScheduler | None = None def __new__(cls) -> CommandScheduler: if cls._instance is None: @@ -71,18 +71,18 @@ def __init__(self) -> None: if CommandScheduler._instance is not None: return CommandScheduler._instance = self - self._composed_commands: Dict[Command, str] = {} + self._composed_commands: dict[Command, str] = {} # A set of the currently-running commands. - self._scheduled_commands: Dict[Command, None] = {} + self._scheduled_commands: dict[Command, None] = {} # A map from required subsystems to their requiring commands. Also used as a set # of the currently-required subsystems. - self._requirements: Dict[Subsystem, Command] = {} + self._requirements: dict[Subsystem, Command] = {} # A map from subsystems registered with the scheduler to their default commands. # Also used as a list of currently-registered subsystems. - self._subsystems: Dict[Subsystem, Optional[Command]] = {} + self._subsystems: dict[Subsystem, Command | None] = {} self._default_button_loop = EventLoop() @@ -93,15 +93,15 @@ def __init__(self) -> None: # Lists of user-supplied actions to be executed on scheduling events for every # command. - self._init_actions: List[Callable[[Command], None]] = [] - self._execute_actions: List[Callable[[Command], None]] = [] - self._interrupt_actions: List[Callable[[Command, Optional[Command]], None]] = [] - self._finish_actions: List[Callable[[Command], None]] = [] + self._init_actions: list[Callable[[Command], None]] = [] + self._execute_actions: list[Callable[[Command], None]] = [] + self._interrupt_actions: list[Callable[[Command, Command | None], None]] = [] + self._finish_actions: list[Callable[[Command], None]] = [] self._in_run_loop = False - self._to_schedule: Dict[Command, None] = {} - self._to_cancel: Dict[Command, Optional[Command]] = {} - self._ending_commands: Set[Command] = set() + self._to_schedule: dict[Command, None] = {} + self._to_cancel: dict[Command, Command | None] = {} + self._ending_commands: set[Command] = set() self._watchdog = Watchdog(TimedRobot.DEFAULT_PERIOD, lambda: None) @@ -170,7 +170,7 @@ def schedule(self, *commands: Command) -> None: for command in commands: self._schedule(command) - def _schedule(self, command: Optional[Command]) -> None: + def _schedule(self, command: Command | None) -> None: if command is None: report_warning("Tried to schedule a null command!", True) return @@ -386,7 +386,7 @@ def remove_default_command(self, subsystem: Subsystem) -> None: self._subsystems[subsystem] = None - def get_default_command(self, subsystem: Subsystem) -> Optional[Command]: + def get_default_command(self, subsystem: Subsystem) -> Command | None: """ Gets the default command associated with this subsystem. Null if this subsystem has no default command associated with it. @@ -412,7 +412,7 @@ def cancel( for command in commands: self._cancel(command, None) - def _cancel(self, command: Command, interruptor: Optional[Command]): + def _cancel(self, command: Command, interruptor: Command | None): if command is None: report_warning("Tried to cancel a null command", True) return @@ -453,7 +453,7 @@ def is_scheduled(self, *commands: Command) -> bool: """ return all(command in self._scheduled_commands for command in commands) - def requiring(self, subsystem: Subsystem) -> Optional[Command]: + def requiring(self, subsystem: Subsystem) -> Command | None: """ Returns the command currently requiring a given subsystem. None if no command is currently requiring the subsystem @@ -507,7 +507,7 @@ def on_command_interrupt(self, action: Callable[[Command], Any]) -> None: self._interrupt_actions.append(lambda command, interruptor: action(command)) def on_command_interrupt_with_cause( - self, action: Callable[[Command, Optional[Command]], Any] + self, action: Callable[[Command, Command | None], Any] ) -> None: """ Adds an action to perform on the interruption of any command by the scheduler. The action receives the interrupted command and the command that interrupted it @@ -621,10 +621,10 @@ def is_composed(self, command: Command) -> bool: """ return command in self._composed_commands - def _get_scheduled_command_names(self) -> List[str]: + def _get_scheduled_command_names(self) -> list[str]: return [command.get_name() for command in self._scheduled_commands] - def _get_scheduled_command_ids(self) -> List[int]: + def _get_scheduled_command_ids(self) -> list[int]: return [id(command) for command in self._scheduled_commands] def log_to(self, table: TelemetryTable) -> None: @@ -654,7 +654,7 @@ def publish_tunables(self, table: TunableTable) -> None: ), ) - def cancel_commands(to_cancel: List[int]): + def cancel_commands(to_cancel: list[int]): ids = {id(command): command for command in self._scheduled_commands} for hash_value in to_cancel: cancel_cmd = ids.get(hash_value) diff --git a/subprojects/robotpy-commands-v2/commands2/conditionalcommand.py b/subprojects/robotpy-commands-v2/commands2/conditionalcommand.py index 34032cb5f..3b9379be7 100644 --- a/subprojects/robotpy-commands-v2/commands2/conditionalcommand.py +++ b/subprojects/robotpy-commands-v2/commands2/conditionalcommand.py @@ -1,7 +1,7 @@ # validated: 2024-01-19 DS aaea85ff1656 ConditionalCommand.java from __future__ import annotations -from typing import Callable, Optional +from collections.abc import Callable from telemetry import TelemetryTable @@ -19,7 +19,7 @@ class ConditionalCommand(Command): subsystems its components require. """ - selected_command: Optional[Command] + selected_command: Command | None def __init__( self, on_true: Command, on_false: Command, condition: Callable[[], bool] diff --git a/subprojects/robotpy-commands-v2/commands2/deferredcommand.py b/subprojects/robotpy-commands-v2/commands2/deferredcommand.py index 2d57b695c..6048b78ae 100644 --- a/subprojects/robotpy-commands-v2/commands2/deferredcommand.py +++ b/subprojects/robotpy-commands-v2/commands2/deferredcommand.py @@ -1,5 +1,5 @@ # validated: 2024-01-24 DS 192a28af4731 DeferredCommand.java -from typing import Callable +from collections.abc import Callable from telemetry import TelemetryTable diff --git a/subprojects/robotpy-commands-v2/commands2/functionalcommand.py b/subprojects/robotpy-commands-v2/commands2/functionalcommand.py index f122e4c3a..bb8bd6dfc 100644 --- a/subprojects/robotpy-commands-v2/commands2/functionalcommand.py +++ b/subprojects/robotpy-commands-v2/commands2/functionalcommand.py @@ -1,7 +1,8 @@ # validated: 2024-01-19 DS 6e58db398d63 FunctionalCommand.java from __future__ import annotations -from typing import Any, Callable +from collections.abc import Callable +from typing import Any from .command import Command from .subsystem import Subsystem diff --git a/subprojects/robotpy-commands-v2/commands2/instantcommand.py b/subprojects/robotpy-commands-v2/commands2/instantcommand.py index e514e3f56..b2d3db5e1 100644 --- a/subprojects/robotpy-commands-v2/commands2/instantcommand.py +++ b/subprojects/robotpy-commands-v2/commands2/instantcommand.py @@ -1,7 +1,7 @@ # validated: 2024-01-19 DS 5cf961edb973 InstantCommand.java from __future__ import annotations -from typing import Callable, Optional +from collections.abc import Callable from .functionalcommand import FunctionalCommand from .subsystem import Subsystem @@ -15,7 +15,7 @@ class InstantCommand(FunctionalCommand): """ def __init__( - self, to_run: Optional[Callable[[], None]] = None, *requirements: Subsystem + self, to_run: Callable[[], None] | None = None, *requirements: Subsystem ): """ Creates a new InstantCommand that runs the given Callable with the given requirements. diff --git a/subprojects/robotpy-commands-v2/commands2/notifiercommand.py b/subprojects/robotpy-commands-v2/commands2/notifiercommand.py index 2a1e317b7..3bb1158b7 100644 --- a/subprojects/robotpy-commands-v2/commands2/notifiercommand.py +++ b/subprojects/robotpy-commands-v2/commands2/notifiercommand.py @@ -1,7 +1,8 @@ # validated: 2024-01-19 DS 6e58db398d63 NotifierCommand.java from __future__ import annotations -from typing import Any, Callable +from collections.abc import Callable +from typing import Any from wpilib import Notifier from wpimath import units diff --git a/subprojects/robotpy-commands-v2/commands2/parallelcommandgroup.py b/subprojects/robotpy-commands-v2/commands2/parallelcommandgroup.py index 56399fc65..e31def527 100644 --- a/subprojects/robotpy-commands-v2/commands2/parallelcommandgroup.py +++ b/subprojects/robotpy-commands-v2/commands2/parallelcommandgroup.py @@ -1,8 +1,6 @@ # validated: 2024-01-19 DS aaea85ff1656 ParallelCommandGroup.java from __future__ import annotations -from typing import Dict - from .command import Command, InterruptionBehavior from .commandscheduler import CommandScheduler from .exceptions import IllegalCommandUse @@ -27,7 +25,7 @@ def __init__(self, *commands: Command): :param commands: the commands to include in this composition. """ super().__init__() - self._commands: Dict[Command, bool] = {} + self._commands: dict[Command, bool] = {} self._runs_when_disabled = True self._interrupt_behavior = InterruptionBehavior.CANCEL_INCOMING self.add_commands(*commands) diff --git a/subprojects/robotpy-commands-v2/commands2/paralleldeadlinegroup.py b/subprojects/robotpy-commands-v2/commands2/paralleldeadlinegroup.py index c71405cba..ec380273c 100644 --- a/subprojects/robotpy-commands-v2/commands2/paralleldeadlinegroup.py +++ b/subprojects/robotpy-commands-v2/commands2/paralleldeadlinegroup.py @@ -1,8 +1,6 @@ # validated: 2024-01-19 DS e07de37e64f2 ParallelDeadlineGroup.java from __future__ import annotations -from typing import Dict - from telemetry import TelemetryTable from .command import Command, InterruptionBehavior @@ -36,7 +34,7 @@ def __init__(self, deadline: Command, *commands: Command): :raises IllegalCommandUse: if the deadline command is also in the commands argument """ super().__init__() - self._commands: Dict[Command, bool] = {} + self._commands: dict[Command, bool] = {} self._runs_when_disabled = True self._finished = True self._interrupt_behavior = InterruptionBehavior.CANCEL_INCOMING diff --git a/subprojects/robotpy-commands-v2/commands2/parallelracegroup.py b/subprojects/robotpy-commands-v2/commands2/parallelracegroup.py index 41dd0f894..ca2e4303f 100644 --- a/subprojects/robotpy-commands-v2/commands2/parallelracegroup.py +++ b/subprojects/robotpy-commands-v2/commands2/parallelracegroup.py @@ -1,8 +1,6 @@ # validated: 2024-01-19 DS aaea85ff1656 ParallelRaceGroup.java from __future__ import annotations -from typing import Set - from .command import Command, InterruptionBehavior from .commandscheduler import CommandScheduler from .exceptions import IllegalCommandUse @@ -28,7 +26,7 @@ def __init__(self, *commands: Command): :param commands: the commands to include in this composition. """ super().__init__() - self._commands: Set[Command] = set() + self._commands: set[Command] = set() self._runs_when_disabled = True self._finished = True self._interrupt_behavior = InterruptionBehavior.CANCEL_INCOMING diff --git a/subprojects/robotpy-commands-v2/commands2/runcommand.py b/subprojects/robotpy-commands-v2/commands2/runcommand.py index b9ff03772..9bf502572 100644 --- a/subprojects/robotpy-commands-v2/commands2/runcommand.py +++ b/subprojects/robotpy-commands-v2/commands2/runcommand.py @@ -1,7 +1,8 @@ # validated: 2024-01-19 DS 5cf961edb973 RunCommand.java from __future__ import annotations -from typing import Any, Callable +from collections.abc import Callable +from typing import Any from .functionalcommand import FunctionalCommand from .subsystem import Subsystem diff --git a/subprojects/robotpy-commands-v2/commands2/selectcommand.py b/subprojects/robotpy-commands-v2/commands2/selectcommand.py index fdc5e91bd..0c3504885 100644 --- a/subprojects/robotpy-commands-v2/commands2/selectcommand.py +++ b/subprojects/robotpy-commands-v2/commands2/selectcommand.py @@ -1,7 +1,7 @@ # validated: 2024-01-19 DS a4a8ad9c753e SelectCommand.java from __future__ import annotations -from typing import Callable, Dict, Hashable +from collections.abc import Callable, Hashable from telemetry import TelemetryTable @@ -22,7 +22,7 @@ class SelectCommand(Command): def __init__( self, - commands: Dict[Hashable, Command], + commands: dict[Hashable, Command], selector: Callable[[], Hashable], ): """ diff --git a/subprojects/robotpy-commands-v2/commands2/sequentialcommandgroup.py b/subprojects/robotpy-commands-v2/commands2/sequentialcommandgroup.py index 0a0c4e221..2c7223153 100644 --- a/subprojects/robotpy-commands-v2/commands2/sequentialcommandgroup.py +++ b/subprojects/robotpy-commands-v2/commands2/sequentialcommandgroup.py @@ -1,8 +1,6 @@ # validated: 2024-01-19 DS aaea85ff1656 SequentialCommandGroup.java from __future__ import annotations -from typing import List - from telemetry import TelemetryTable from .command import Command, InterruptionBehavior @@ -28,7 +26,7 @@ def __init__(self, *commands: Command): :param commands: the commands to include in this composition. """ super().__init__() - self._commands: List[Command] = [] + self._commands: list[Command] = [] self._current_command_index = -1 self._runs_when_disabled = True self._interrupt_behavior = InterruptionBehavior.CANCEL_INCOMING diff --git a/subprojects/robotpy-commands-v2/commands2/startendcommand.py b/subprojects/robotpy-commands-v2/commands2/startendcommand.py index e95548cfa..4cc434421 100644 --- a/subprojects/robotpy-commands-v2/commands2/startendcommand.py +++ b/subprojects/robotpy-commands-v2/commands2/startendcommand.py @@ -1,7 +1,8 @@ # validated: 2024-01-19 DS b390cad09505 StartEndCommand.java from __future__ import annotations -from typing import Any, Callable +from collections.abc import Callable +from typing import Any from .functionalcommand import FunctionalCommand from .subsystem import Subsystem diff --git a/subprojects/robotpy-commands-v2/commands2/subsystem.py b/subprojects/robotpy-commands-v2/commands2/subsystem.py index ddb7cfe47..3cbfbfe34 100644 --- a/subprojects/robotpy-commands-v2/commands2/subsystem.py +++ b/subprojects/robotpy-commands-v2/commands2/subsystem.py @@ -3,12 +3,11 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, Callable, Optional -from typing_extensions import Self +from collections.abc import Callable +from typing import TYPE_CHECKING, Self if TYPE_CHECKING: from .command import Command - from .commandscheduler import CommandScheduler from telemetry import TelemetryLoggable, TelemetryTable @@ -79,7 +78,7 @@ def remove_default_command(self) -> None: CommandScheduler.get_instance().remove_default_command(self) - def get_default_command(self) -> Optional[Command]: + def get_default_command(self) -> Command | None: """ Gets the default command for this subsystem. Returns None if no default command is currently associated with the subsystem. @@ -90,7 +89,7 @@ def get_default_command(self) -> Optional[Command]: return CommandScheduler.get_instance().get_default_command(self) - def get_current_command(self) -> Optional[Command]: + def get_current_command(self) -> Command | None: """ Returns the command currently running on this subsystem. Returns None if no command is currently scheduled that requires this subsystem. diff --git a/subprojects/robotpy-commands-v2/commands2/sysid/sysidroutine.py b/subprojects/robotpy-commands-v2/commands2/sysid/sysidroutine.py index 7fc1558c0..1067b32b7 100644 --- a/subprojects/robotpy-commands-v2/commands2/sysid/sysidroutine.py +++ b/subprojects/robotpy-commands-v2/commands2/sysid/sysidroutine.py @@ -1,15 +1,14 @@ # validated: 2024-02-20 DV ee15cc172a5e sysid/SysIdRoutine.java -from dataclasses import dataclass, field +from collections.abc import Callable +from dataclasses import dataclass from enum import Enum -from wpilib.sysid import SysIdRoutineLog, State -from ..command import Command -from ..subsystem import Subsystem from wpilib import Timer - +from wpilib.sysid import State, SysIdRoutineLog from wpimath.units import seconds, volts -from typing import Callable, Optional +from ..command import Command +from ..subsystem import Subsystem volts_per_second = float @@ -51,7 +50,7 @@ class Config: ramp_rate: volts_per_second = 1.0 step_voltage: volts = 7.0 timeout: seconds = 10.0 - record_state: Optional[Callable[[State], None]] = None + record_state: Callable[[State], None] | None = None @dataclass class Mechanism: diff --git a/subprojects/robotpy-commands-v2/commands2/typing.py b/subprojects/robotpy-commands-v2/commands2/typing.py index ddec81ae7..85951ecd9 100644 --- a/subprojects/robotpy-commands-v2/commands2/typing.py +++ b/subprojects/robotpy-commands-v2/commands2/typing.py @@ -1,7 +1,5 @@ -from typing import Callable, Union - -from typing_extensions import TypeAlias +from collections.abc import Callable # Type Aliases -FloatSupplier: TypeAlias = Callable[[], float] -FloatOrFloatSupplier: TypeAlias = Union[float, Callable[[], float]] +type FloatSupplier = Callable[[], float] +type FloatOrFloatSupplier = float | FloatSupplier diff --git a/subprojects/robotpy-commands-v2/commands2/util.py b/subprojects/robotpy-commands-v2/commands2/util.py index e0178c941..c83ee39e0 100644 --- a/subprojects/robotpy-commands-v2/commands2/util.py +++ b/subprojects/robotpy-commands-v2/commands2/util.py @@ -1,15 +1,15 @@ # notrack from __future__ import annotations -from typing import Iterable, List, Tuple, Union +from collections.abc import Iterable from .command import Command def flatten_args_commands( - *commands: Union[Command, Iterable[Command]] -) -> Tuple[Command, ...]: - flattened_commands: List[Command] = [] + *commands: Command | Iterable[Command], +) -> tuple[Command, ...]: + flattened_commands: list[Command] = [] for command in commands: if isinstance(command, Command): flattened_commands.append(command) diff --git a/subprojects/robotpy-commands-v2/commands2/waituntilcommand.py b/subprojects/robotpy-commands-v2/commands2/waituntilcommand.py index aa5c1f9fe..24ad9f2c0 100644 --- a/subprojects/robotpy-commands-v2/commands2/waituntilcommand.py +++ b/subprojects/robotpy-commands-v2/commands2/waituntilcommand.py @@ -1,7 +1,8 @@ # validated: 2024-01-20 DS aaea85ff1656 WaitUntilCommand.java from __future__ import annotations -from typing import Callable, overload +from collections.abc import Callable +from typing import overload from wpilib import Timer from wpimath import units diff --git a/subprojects/robotpy-commands-v2/commands2/wrappercommand.py b/subprojects/robotpy-commands-v2/commands2/wrappercommand.py index e9202d5e8..edf9a2487 100644 --- a/subprojects/robotpy-commands-v2/commands2/wrappercommand.py +++ b/subprojects/robotpy-commands-v2/commands2/wrappercommand.py @@ -1,8 +1,6 @@ # validated: 2024-01-20 DS ad0859a8c9ec WrapperCommand.java from __future__ import annotations -from typing import Set - from .command import Command, InterruptionBehavior from .commandscheduler import CommandScheduler @@ -63,7 +61,7 @@ def is_finished(self) -> bool: """ return self._command.is_finished() - def get_requirements(self) -> Set: + def get_requirements(self) -> set: """ Specifies the set of subsystems used by this command. Two commands cannot use the same subsystem at the same time. If the command is scheduled as interruptible and another command is diff --git a/subprojects/robotpy-commands-v2/pyproject.in.toml b/subprojects/robotpy-commands-v2/pyproject.in.toml index ec6b88e6f..c4dab6e9e 100644 --- a/subprojects/robotpy-commands-v2/pyproject.in.toml +++ b/subprojects/robotpy-commands-v2/pyproject.in.toml @@ -7,12 +7,11 @@ name = "robotpy-commands-v2" version = "0.0.0" description = "WPILib command framework v2" readme = "README.md" -requires-python = ">=3.11" +requires-python = ">=3.12" license = "BSD-3-Clause" license-files = ["LICENSE"] dependencies = [ "wpilib==0.0.0", - "typing_extensions>=4.1.0,<5", ] [[project.authors]] diff --git a/subprojects/robotpy-commands-v2/tests/compositiontestbase.py b/subprojects/robotpy-commands-v2/tests/compositiontestbase.py index 036a9c221..aca55ac8f 100644 --- a/subprojects/robotpy-commands-v2/tests/compositiontestbase.py +++ b/subprojects/robotpy-commands-v2/tests/compositiontestbase.py @@ -1,5 +1,3 @@ -from typing import Generic, TypeVar - import commands2 import pytest diff --git a/subprojects/robotpy-commands-v2/tests/test_command_decorators.py b/subprojects/robotpy-commands-v2/tests/test_command_decorators.py index 5aeeaa113..f0e330cf0 100644 --- a/subprojects/robotpy-commands-v2/tests/test_command_decorators.py +++ b/subprojects/robotpy-commands-v2/tests/test_command_decorators.py @@ -7,6 +7,7 @@ import commands2 import pytest +from wpilib.simulation import DriverStationSim def test_timeout(scheduler: commands2.CommandScheduler): diff --git a/subprojects/robotpy-commands-v2/tests/test_command_schedule.py b/subprojects/robotpy-commands-v2/tests/test_command_schedule.py index 00ad22654..9a56d6418 100644 --- a/subprojects/robotpy-commands-v2/tests/test_command_schedule.py +++ b/subprojects/robotpy-commands-v2/tests/test_command_schedule.py @@ -6,8 +6,6 @@ if TYPE_CHECKING: from .util import * -import pytest - def test_instant_schedule(scheduler: commands2.CommandScheduler): command = commands2.Command() diff --git a/subprojects/robotpy-commands-v2/tests/test_conditional_command.py b/subprojects/robotpy-commands-v2/tests/test_conditional_command.py index 4625bc42a..f81639ee7 100644 --- a/subprojects/robotpy-commands-v2/tests/test_conditional_command.py +++ b/subprojects/robotpy-commands-v2/tests/test_conditional_command.py @@ -6,8 +6,6 @@ if TYPE_CHECKING: from .util import * -import pytest - def test_conditional_command(scheduler: commands2.CommandScheduler): command1 = commands2.Command() diff --git a/subprojects/robotpy-commands-v2/tests/test_default_command.py b/subprojects/robotpy-commands-v2/tests/test_default_command.py index df698f00f..3d0956308 100644 --- a/subprojects/robotpy-commands-v2/tests/test_default_command.py +++ b/subprojects/robotpy-commands-v2/tests/test_default_command.py @@ -1,13 +1,13 @@ from typing import TYPE_CHECKING import commands2 +from wpilib.simulation import DriverStationSim + from util import * # type: ignore if TYPE_CHECKING: from .util import * -import pytest - def test_default_command_schedule(scheduler: commands2.CommandScheduler): has_default_command = commands2.Subsystem() diff --git a/subprojects/robotpy-commands-v2/tests/test_functional_command.py b/subprojects/robotpy-commands-v2/tests/test_functional_command.py index ff5e9b9ba..a2baa892b 100644 --- a/subprojects/robotpy-commands-v2/tests/test_functional_command.py +++ b/subprojects/robotpy-commands-v2/tests/test_functional_command.py @@ -6,8 +6,6 @@ if TYPE_CHECKING: from .util import * -import pytest - def test_functional_command_schedule(scheduler: commands2.CommandScheduler): cond1 = OOBoolean() diff --git a/subprojects/robotpy-commands-v2/tests/test_instant_command.py b/subprojects/robotpy-commands-v2/tests/test_instant_command.py index 006727b22..c9db11cee 100644 --- a/subprojects/robotpy-commands-v2/tests/test_instant_command.py +++ b/subprojects/robotpy-commands-v2/tests/test_instant_command.py @@ -6,8 +6,6 @@ if TYPE_CHECKING: from .util import * -import pytest - def test_instant_command_schedule(scheduler: commands2.CommandScheduler): cond = OOBoolean() diff --git a/subprojects/robotpy-commands-v2/tests/test_notifier_command.py b/subprojects/robotpy-commands-v2/tests/test_notifier_command.py index 59144b72c..22e9dfe69 100644 --- a/subprojects/robotpy-commands-v2/tests/test_notifier_command.py +++ b/subprojects/robotpy-commands-v2/tests/test_notifier_command.py @@ -6,8 +6,6 @@ if TYPE_CHECKING: from .util import * -import pytest - def test_notifier_command_scheduler(scheduler: commands2.CommandScheduler): with ManualSimTime() as sim: diff --git a/subprojects/robotpy-commands-v2/tests/test_printcommand.py b/subprojects/robotpy-commands-v2/tests/test_printcommand.py index 295b8f116..bed491e7b 100644 --- a/subprojects/robotpy-commands-v2/tests/test_printcommand.py +++ b/subprojects/robotpy-commands-v2/tests/test_printcommand.py @@ -6,8 +6,6 @@ if TYPE_CHECKING: from .util import * -import pytest - def test_print_command_schedule(capsys, scheduler: commands2.CommandScheduler): command = commands2.PrintCommand("Test!") diff --git a/subprojects/robotpy-commands-v2/tests/test_proxycommand.py b/subprojects/robotpy-commands-v2/tests/test_proxycommand.py index b063bec66..451fd0b66 100644 --- a/subprojects/robotpy-commands-v2/tests/test_proxycommand.py +++ b/subprojects/robotpy-commands-v2/tests/test_proxycommand.py @@ -6,8 +6,6 @@ if TYPE_CHECKING: from .util import * -import pytest - def test_proxy_command_schedule(scheduler: commands2.CommandScheduler): command1 = commands2.Command() diff --git a/subprojects/robotpy-commands-v2/tests/test_repeatcommand.py b/subprojects/robotpy-commands-v2/tests/test_repeatcommand.py index 819392151..73333f4e2 100644 --- a/subprojects/robotpy-commands-v2/tests/test_repeatcommand.py +++ b/subprojects/robotpy-commands-v2/tests/test_repeatcommand.py @@ -8,8 +8,6 @@ from .util import * from .compositiontestbase import SingleCompositionTestBase -import pytest - class RepeatCommandCompositionTest(SingleCompositionTestBase): def compose_single(self, member): diff --git a/subprojects/robotpy-commands-v2/tests/test_robotdisabledcommand.py b/subprojects/robotpy-commands-v2/tests/test_robotdisabledcommand.py index 3047ce00c..16e8354d7 100644 --- a/subprojects/robotpy-commands-v2/tests/test_robotdisabledcommand.py +++ b/subprojects/robotpy-commands-v2/tests/test_robotdisabledcommand.py @@ -1,13 +1,13 @@ from typing import TYPE_CHECKING import commands2 +from wpilib.simulation import DriverStationSim + from util import * # type: ignore if TYPE_CHECKING: from .util import * -import pytest - def test_robot_disabled_command_cancel(scheduler: commands2.CommandScheduler): command = commands2.Command() diff --git a/subprojects/robotpy-commands-v2/tests/test_runcommand.py b/subprojects/robotpy-commands-v2/tests/test_runcommand.py index 2b432f7e1..cc65fe54d 100644 --- a/subprojects/robotpy-commands-v2/tests/test_runcommand.py +++ b/subprojects/robotpy-commands-v2/tests/test_runcommand.py @@ -6,8 +6,6 @@ if TYPE_CHECKING: from .util import * -import pytest - def test_run_command_schedule(scheduler: commands2.CommandScheduler): counter = OOInteger(0) diff --git a/subprojects/robotpy-commands-v2/tests/test_schedulecommand.py b/subprojects/robotpy-commands-v2/tests/test_schedulecommand.py index 8ab60a02f..51f7a4cf0 100644 --- a/subprojects/robotpy-commands-v2/tests/test_schedulecommand.py +++ b/subprojects/robotpy-commands-v2/tests/test_schedulecommand.py @@ -6,8 +6,6 @@ if TYPE_CHECKING: from .util import * -import pytest - def test_schedule_command_schedule(scheduler: commands2.CommandScheduler): command1 = commands2.Command() diff --git a/subprojects/robotpy-commands-v2/tests/test_scheduler.py b/subprojects/robotpy-commands-v2/tests/test_scheduler.py index b7e6e5418..3871d8490 100644 --- a/subprojects/robotpy-commands-v2/tests/test_scheduler.py +++ b/subprojects/robotpy-commands-v2/tests/test_scheduler.py @@ -6,11 +6,9 @@ if TYPE_CHECKING: from .util import * -import pytest import telemetry import telemetry.mock_backend as mock_backend import tunables -import wpilib def test_scheduler_lambda_test_no_interrupt(scheduler: commands2.CommandScheduler): diff --git a/subprojects/robotpy-commands-v2/tests/test_selectcommand.py b/subprojects/robotpy-commands-v2/tests/test_selectcommand.py index b9a4e30a7..691324382 100644 --- a/subprojects/robotpy-commands-v2/tests/test_selectcommand.py +++ b/subprojects/robotpy-commands-v2/tests/test_selectcommand.py @@ -8,8 +8,6 @@ from .util import * from .compositiontestbase import MultiCompositionTestBase -import pytest - class TestSelectCommandComposition(MultiCompositionTestBase): def compose(self, *members: commands2.Command): diff --git a/subprojects/robotpy-commands-v2/tests/test_sequentialcommandgroup.py b/subprojects/robotpy-commands-v2/tests/test_sequentialcommandgroup.py index 3eea8167d..4a49d7f46 100644 --- a/subprojects/robotpy-commands-v2/tests/test_sequentialcommandgroup.py +++ b/subprojects/robotpy-commands-v2/tests/test_sequentialcommandgroup.py @@ -8,8 +8,6 @@ from .util import * from .compositiontestbase import MultiCompositionTestBase -import pytest - class TestSequentialCommandGroupComposition(MultiCompositionTestBase): def compose(self, *members: commands2.Command): diff --git a/subprojects/robotpy-commands-v2/tests/test_startendcommand.py b/subprojects/robotpy-commands-v2/tests/test_startendcommand.py index 25ad9b736..fc4c4657d 100644 --- a/subprojects/robotpy-commands-v2/tests/test_startendcommand.py +++ b/subprojects/robotpy-commands-v2/tests/test_startendcommand.py @@ -6,8 +6,6 @@ if TYPE_CHECKING: from .util import * -import pytest - def test_start_end_command_schedule(scheduler: commands2.CommandScheduler): cond1 = OOBoolean(False) diff --git a/subprojects/robotpy-commands-v2/tests/test_waitcommand.py b/subprojects/robotpy-commands-v2/tests/test_waitcommand.py index 37fe1666c..607168404 100644 --- a/subprojects/robotpy-commands-v2/tests/test_waitcommand.py +++ b/subprojects/robotpy-commands-v2/tests/test_waitcommand.py @@ -6,8 +6,6 @@ if TYPE_CHECKING: from .util import * -import pytest - def test_wait_command(scheduler: commands2.CommandScheduler): with ManualSimTime() as sim: diff --git a/subprojects/robotpy-commands-v2/tests/test_waituntilcommand.py b/subprojects/robotpy-commands-v2/tests/test_waituntilcommand.py index 395f1708a..f9651b5d7 100644 --- a/subprojects/robotpy-commands-v2/tests/test_waituntilcommand.py +++ b/subprojects/robotpy-commands-v2/tests/test_waituntilcommand.py @@ -6,8 +6,6 @@ if TYPE_CHECKING: from .util import * -import pytest - def test_wait_until(scheduler: commands2.CommandScheduler): condition = OOBoolean() diff --git a/subprojects/robotpy-commands-v2/tests/util.py b/subprojects/robotpy-commands-v2/tests/util.py index 7e1b24ef9..c8d70ea96 100644 --- a/subprojects/robotpy-commands-v2/tests/util.py +++ b/subprojects/robotpy-commands-v2/tests/util.py @@ -1,14 +1,13 @@ -from typing import Any, Dict, TypeVar, Type - import inspect +from typing import Any, TypeVar import commands2 -from wpilib.simulation import DriverStationSim, pause_timing, resume_timing, step_timing +from wpilib.simulation import pause_timing, resume_timing, step_timing Y = TypeVar("Y") -def full_subclass_of(cls: Type[Y]) -> Type[Y]: +def full_subclass_of(cls: type[Y]) -> type[Y]: # Pybind classes can't be monkeypatched. # This generates a subclass with every method filled out # so that it can be monkeypatched. @@ -138,7 +137,7 @@ def __name__(self) -> str: # Fakito Framework -def _get_all_args_as_kwargs(method, *args, **kwargs) -> Dict[str, Any]: +def _get_all_args_as_kwargs(method, *args, **kwargs) -> dict[str, Any]: try: import inspect diff --git a/subprojects/robotpy-commands-v2/tools/hids/templates/main/python/first_ds_commandhid.py.jinja b/subprojects/robotpy-commands-v2/tools/hids/templates/main/python/first_ds_commandhid.py.jinja index 3bb307eff..4d4b94348 100644 --- a/subprojects/robotpy-commands-v2/tools/hids/templates/main/python/first_ds_commandhid.py.jinja +++ b/subprojects/robotpy-commands-v2/tools/hids/templates/main/python/first_ds_commandhid.py.jinja @@ -1,7 +1,5 @@ # THIS FILE WAS AUTO-GENERATED BY ./commandsv2/generate_hids.py. DO NOT MODIFY -from typing import Optional, Union - from wpilib import EventLoop, {{ ClassName }}Controller from .commandgenerichid import CommandGenericHID @@ -16,7 +14,7 @@ class Command{{ ClassName }}Controller: _hid: CommandGenericHID _controller: {{ ClassName }}Controller - def __init__(self, hid: Union[int, {{ ClassName }}Controller]): + def __init__(self, hid: int | {{ ClassName }}Controller): """ Construct an instance of a controller. @@ -49,7 +47,7 @@ class Command{{ ClassName }}Controller: def button( self, button: {{ ClassName }}Controller.Button, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs an event instance around this button's digital signal. @@ -59,7 +57,7 @@ class Command{{ ClassName }}Controller: """ return self._hid.button(button.value, loop) {% for button in buttons %} - def {{ button.PythonName }}(self, loop: Optional[EventLoop] = None) -> Trigger: + def {{ button.PythonName }}(self, loop: EventLoop | None = None) -> Trigger: """ Constructs a Trigger instance around the {{ button.PythonDocName }} button's digital signal. @@ -75,7 +73,7 @@ class Command{{ ClassName }}Controller: def {{ trigger.PythonName }}( self, threshold: float{% if trigger.HasDefaultThresholdMethod %} = 0.5{% endif %}, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs a Trigger instance around the {{ trigger.PythonDocName }} axis value. The returned @@ -99,7 +97,7 @@ class Command{{ ClassName }}Controller: self, axis: {{ ClassName }}Controller.Axis, threshold: float, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs a Trigger instance that is true when the axis value is less than @@ -118,7 +116,7 @@ class Command{{ ClassName }}Controller: self, axis: {{ ClassName }}Controller.Axis, threshold: float, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs a Trigger instance that is true when the axis value is greater @@ -137,7 +135,7 @@ class Command{{ ClassName }}Controller: self, axis: {{ ClassName }}Controller.Axis, threshold: float, - loop: Optional[EventLoop] = None, + loop: EventLoop | None = None, ) -> Trigger: """ Constructs a Trigger instance that is true when the axis magnitude is diff --git a/subprojects/robotpy-cscore/cscore/_logging.py b/subprojects/robotpy-cscore/cscore/_logging.py index 5e5de15c7..34b012883 100644 --- a/subprojects/robotpy-cscore/cscore/_logging.py +++ b/subprojects/robotpy-cscore/cscore/_logging.py @@ -1,10 +1,9 @@ import logging -import typing from ._cscore import _set_logger -def enable_logging(level: typing.Optional[int] = None): +def enable_logging(level: int | None = None): """Enable logging for cscore""" if level is None: level = logging.DEBUG diff --git a/subprojects/robotpy-cscore/cscore/imagewriter.py b/subprojects/robotpy-cscore/cscore/imagewriter.py index dfff4f1e6..95fd6f008 100644 --- a/subprojects/robotpy-cscore/cscore/imagewriter.py +++ b/subprojects/robotpy-cscore/cscore/imagewriter.py @@ -46,7 +46,7 @@ def __init__( *, location_root="/media/sda1/camera", capture_period=0.5, - image_format="jpg" + image_format="jpg", ): """ :param location_root: Directory to write images to. A subdirectory diff --git a/subprojects/robotpy-cscore/pyproject.in.toml b/subprojects/robotpy-cscore/pyproject.in.toml index 584f7bfcb..020354a3b 100644 --- a/subprojects/robotpy-cscore/pyproject.in.toml +++ b/subprojects/robotpy-cscore/pyproject.in.toml @@ -6,8 +6,8 @@ requires = [ "hatch-robotpy==0.0.0", "hatchling", "wpilib==0.0.0", + "robotpy-native-wpinet==0.0.0", "robotpy-wpiutil==0.0.0", - "robotpy-wpinet==0.0.0", "pyntcore==0.0.0", # "numpy", # required for pybind11-stubgen to not complain, broken in raspbian CI ] @@ -21,8 +21,8 @@ authors = [ ] license = "BSD-3-Clause" dependencies = [ + "robotpy-native-wpinet==0.0.0", "robotpy-wpiutil==0.0.0", - "robotpy-wpinet==0.0.0", "pyntcore==0.0.0", ] diff --git a/subprojects/robotpy-fields/pyproject.in.toml b/subprojects/robotpy-fields/pyproject.in.toml index 880bbbd42..86bf25bec 100644 --- a/subprojects/robotpy-fields/pyproject.in.toml +++ b/subprojects/robotpy-fields/pyproject.in.toml @@ -14,7 +14,7 @@ requires = [ name = "robotpy-fields" version = "0.0.0" description = "RobotPy bindings for WPILib's fields library" -requires-python = ">=3.11" +requires-python = ">=3.12" authors = [ {name = "RobotPy Development Team", email = "robotpy@googlegroups.com"}, ] diff --git a/subprojects/robotpy-hal/hal/simulation/mockhooks.py b/subprojects/robotpy-hal/hal/simulation/mockhooks.py index 1aa42f6e4..07c0151a3 100644 --- a/subprojects/robotpy-hal/hal/simulation/mockhooks.py +++ b/subprojects/robotpy-hal/hal/simulation/mockhooks.py @@ -1,11 +1,10 @@ import time -import typing as T from ._simulation import get_next_notifier_timeout, get_program_started def wait_for_program_start( - timeout: T.Optional[float] = None, + timeout: float | None = None, delta: float = 0.001, wait_for_first_notifier: bool = True, ): diff --git a/subprojects/robotpy-hal/pyproject.in.toml b/subprojects/robotpy-hal/pyproject.in.toml index d767db313..2297e2db8 100644 --- a/subprojects/robotpy-hal/pyproject.in.toml +++ b/subprojects/robotpy-hal/pyproject.in.toml @@ -13,7 +13,7 @@ requires = [ name = "robotpy-hal" version = "0.0.0" description = "Binary wrapper for WPILib HAL" -requires-python = ">=3.11" +requires-python = ">=3.12" authors = [ {name = "RobotPy Development Team", email = "robotpy@googlegroups.com"}, ] diff --git a/subprojects/robotpy-hal/tests/test_hal_simulation.py b/subprojects/robotpy-hal/tests/test_hal_simulation.py index ebadd5717..e1f7ae5c9 100644 --- a/subprojects/robotpy-hal/tests/test_hal_simulation.py +++ b/subprojects/robotpy-hal/tests/test_hal_simulation.py @@ -6,7 +6,7 @@ def test_value_changed_callback(): - recv: typing.Optional[typing.Tuple[bool, str, int]] = None + recv: tuple[bool, str, int] | None = None def created_cb( name: str, handle: int, direction: hal.SimValueDirection, value: hal.Value diff --git a/subprojects/robotpy-halsim-ds-socket/pyproject.in.toml b/subprojects/robotpy-halsim-ds-socket/pyproject.in.toml index bbe635c5a..9f396b70d 100644 --- a/subprojects/robotpy-halsim-ds-socket/pyproject.in.toml +++ b/subprojects/robotpy-halsim-ds-socket/pyproject.in.toml @@ -9,7 +9,7 @@ requires = [ name = "robotpy-halsim-ds-socket" version = "0.0.0" description = "WPILib simulator DS Socket Extension" -requires-python = ">=3.11" +requires-python = ">=3.12" authors = [ {name = "RobotPy Development Team", email = "robotpy@googlegroups.com"}, ] diff --git a/subprojects/robotpy-halsim-gui/pyproject.in.toml b/subprojects/robotpy-halsim-gui/pyproject.in.toml index 9d4c312bc..510a8581a 100644 --- a/subprojects/robotpy-halsim-gui/pyproject.in.toml +++ b/subprojects/robotpy-halsim-gui/pyproject.in.toml @@ -16,7 +16,7 @@ requires = [ name = "robotpy-halsim-gui" version = "0.0.0" description = "WPILib simulation GUI" -requires-python = ">=3.11" +requires-python = ">=3.12" authors = [ {name = "RobotPy Development Team", email = "robotpy@googlegroups.com"}, ] diff --git a/subprojects/robotpy-halsim-ws/pyproject.in.toml b/subprojects/robotpy-halsim-ws/pyproject.in.toml index ce77f0acd..0cd953edc 100644 --- a/subprojects/robotpy-halsim-ws/pyproject.in.toml +++ b/subprojects/robotpy-halsim-ws/pyproject.in.toml @@ -9,7 +9,7 @@ requires = [ name = "robotpy-halsim-ws" version = "0.0.0" description = "WPILib simulator websim Extensions" -requires-python = ">=3.11" +requires-python = ">=3.12" authors = [ {name = "RobotPy Development Team", email = "robotpy@googlegroups.com"}, ] diff --git a/subprojects/robotpy-native-apriltag/pyproject.in.toml b/subprojects/robotpy-native-apriltag/pyproject.in.toml index a6272146f..4ff78822a 100644 --- a/subprojects/robotpy-native-apriltag/pyproject.in.toml +++ b/subprojects/robotpy-native-apriltag/pyproject.in.toml @@ -12,7 +12,7 @@ requires = [ name = "robotpy-native-apriltag" version = "0.0.0" description = "WPILib AprilTag Library" -requires-python = ">=3.11" +requires-python = ">=3.12" license = "BSD-3-Clause" dependencies = [ diff --git a/subprojects/robotpy-native-datalog/pyproject.in.toml b/subprojects/robotpy-native-datalog/pyproject.in.toml index 7cda4d9fe..ad2d80fe5 100644 --- a/subprojects/robotpy-native-datalog/pyproject.in.toml +++ b/subprojects/robotpy-native-datalog/pyproject.in.toml @@ -11,7 +11,7 @@ requires = [ name = "robotpy-native-datalog" version = "0.0.0" description = "WPILib Utility Library" -requires-python = ">=3.11" +requires-python = ">=3.12" license = "BSD-3-Clause" dependencies = [ diff --git a/subprojects/robotpy-native-fields/pyproject.in.toml b/subprojects/robotpy-native-fields/pyproject.in.toml index 1d6029285..867e638a0 100644 --- a/subprojects/robotpy-native-fields/pyproject.in.toml +++ b/subprojects/robotpy-native-fields/pyproject.in.toml @@ -12,7 +12,7 @@ requires = [ name = "robotpy-native-fields" version = "0.0.0" description = "WPILib Fields Library" -requires-python = ">=3.11" +requires-python = ">=3.12" license = "BSD-3-Clause" dependencies = [ diff --git a/subprojects/robotpy-native-halsim-gui/pyproject.in.toml b/subprojects/robotpy-native-halsim-gui/pyproject.in.toml index 8a8fa0f26..8258690fe 100644 --- a/subprojects/robotpy-native-halsim-gui/pyproject.in.toml +++ b/subprojects/robotpy-native-halsim-gui/pyproject.in.toml @@ -13,7 +13,7 @@ requires = [ name = "robotpy-native-halsim-gui" version = "0.0.0" description = "WPILib HALSim GUI native library" -requires-python = ">=3.11" +requires-python = ">=3.12" license = "BSD-3-Clause" dependencies = [ diff --git a/subprojects/robotpy-native-ntcore/pyproject.in.toml b/subprojects/robotpy-native-ntcore/pyproject.in.toml index 82ab85955..c7d6ee81e 100644 --- a/subprojects/robotpy-native-ntcore/pyproject.in.toml +++ b/subprojects/robotpy-native-ntcore/pyproject.in.toml @@ -13,7 +13,7 @@ requires = [ name = "robotpy-native-ntcore" version = "0.0.0" description = "WPILib NetworkTables Library" -requires-python = ">=3.11" +requires-python = ">=3.12" license = "BSD-3-Clause" dependencies = [ diff --git a/subprojects/robotpy-native-romi/pyproject.in.toml b/subprojects/robotpy-native-romi/pyproject.in.toml index 51b57187b..c32f8f998 100644 --- a/subprojects/robotpy-native-romi/pyproject.in.toml +++ b/subprojects/robotpy-native-romi/pyproject.in.toml @@ -11,7 +11,7 @@ requires = [ name = "robotpy-native-romi" version = "0.0.0" description = "WPILib Romi support library" -requires-python = ">=3.11" +requires-python = ">=3.12" license = "BSD-3-Clause" dependencies = [ diff --git a/subprojects/robotpy-native-wpihal/pyproject.in.toml b/subprojects/robotpy-native-wpihal/pyproject.in.toml index 38bb88376..8784150f6 100644 --- a/subprojects/robotpy-native-wpihal/pyproject.in.toml +++ b/subprojects/robotpy-native-wpihal/pyproject.in.toml @@ -12,7 +12,7 @@ requires = [ name = "robotpy-native-wpihal" version = "0.0.0" description = "WPILib HAL implementation" -requires-python = ">=3.11" +requires-python = ">=3.12" license = "BSD-3-Clause" dependencies = [ diff --git a/subprojects/robotpy-native-wpilib-drivers/pyproject.in.toml b/subprojects/robotpy-native-wpilib-drivers/pyproject.in.toml index 3d065ae21..b18ddcd39 100644 --- a/subprojects/robotpy-native-wpilib-drivers/pyproject.in.toml +++ b/subprojects/robotpy-native-wpilib-drivers/pyproject.in.toml @@ -11,7 +11,7 @@ requires = [ name = "robotpy-native-wpilib-drivers" version = "0.0.0" description = "WPILib third-party drivers library" -requires-python = ">=3.11" +requires-python = ">=3.12" license = "BSD-3-Clause" dependencies = [ diff --git a/subprojects/robotpy-native-wpilib/pyproject.in.toml b/subprojects/robotpy-native-wpilib/pyproject.in.toml index aa11e561b..afea8e509 100644 --- a/subprojects/robotpy-native-wpilib/pyproject.in.toml +++ b/subprojects/robotpy-native-wpilib/pyproject.in.toml @@ -17,7 +17,7 @@ requires = [ name = "robotpy-native-wpilib" version = "0.0.0" description = "WPILib Robotics Library" -requires-python = ">=3.11" +requires-python = ">=3.12" license = "BSD-3-Clause" dependencies = [ diff --git a/subprojects/robotpy-native-wpimath/pyproject.in.toml b/subprojects/robotpy-native-wpimath/pyproject.in.toml index a216ab11c..024865d1e 100644 --- a/subprojects/robotpy-native-wpimath/pyproject.in.toml +++ b/subprojects/robotpy-native-wpimath/pyproject.in.toml @@ -13,7 +13,7 @@ requires = [ name = "robotpy-native-wpimath" version = "0.0.0" description = "WPILib Math Library" -requires-python = ">=3.11" +requires-python = ">=3.12" license = "BSD-3-Clause" dependencies = [ diff --git a/subprojects/robotpy-native-wpinet/pyproject.in.toml b/subprojects/robotpy-native-wpinet/pyproject.in.toml index 5b5abb680..2be4be2fa 100644 --- a/subprojects/robotpy-native-wpinet/pyproject.in.toml +++ b/subprojects/robotpy-native-wpinet/pyproject.in.toml @@ -11,7 +11,7 @@ requires = [ name = "robotpy-native-wpinet" version = "0.0.0" description = "WPILib Networking Library" -requires-python = ">=3.11" +requires-python = ">=3.12" license = "BSD-3-Clause" dependencies = [ diff --git a/subprojects/robotpy-native-wpiutil/pyproject.in.toml b/subprojects/robotpy-native-wpiutil/pyproject.in.toml index 3aad1044f..659e97d5b 100644 --- a/subprojects/robotpy-native-wpiutil/pyproject.in.toml +++ b/subprojects/robotpy-native-wpiutil/pyproject.in.toml @@ -10,7 +10,7 @@ requires = [ name = "robotpy-native-wpiutil" version = "0.0.0" description = "WPILib Utility Library" -requires-python = ">=3.11" +requires-python = ">=3.12" license = "BSD-3-Clause" dependencies = [ diff --git a/subprojects/robotpy-native-xrp/pyproject.in.toml b/subprojects/robotpy-native-xrp/pyproject.in.toml index 83bc2651d..5180971ca 100644 --- a/subprojects/robotpy-native-xrp/pyproject.in.toml +++ b/subprojects/robotpy-native-xrp/pyproject.in.toml @@ -11,7 +11,7 @@ requires = [ name = "robotpy-native-xrp" version = "0.0.0" description = "WPILib XRP vendor library" -requires-python = ">=3.11" +requires-python = ">=3.12" license = "BSD-3-Clause" dependencies = [ diff --git a/subprojects/robotpy-romi/pyproject.in.toml b/subprojects/robotpy-romi/pyproject.in.toml index 847c1ba13..741142775 100644 --- a/subprojects/robotpy-romi/pyproject.in.toml +++ b/subprojects/robotpy-romi/pyproject.in.toml @@ -14,7 +14,7 @@ requires = [ name = "robotpy-romi" version = "0.0.0" description = "Binary wrapper for WPILib Romi Vendor library" -requires-python = ">=3.11" +requires-python = ">=3.12" authors = [ {name = "RobotPy Development Team", email = "robotpy@googlegroups.com"}, ] diff --git a/subprojects/robotpy-romi/romi/cli.py b/subprojects/robotpy-romi/romi/cli.py index d03652c87..6ff5a63bd 100644 --- a/subprojects/robotpy-romi/romi/cli.py +++ b/subprojects/robotpy-romi/romi/cli.py @@ -2,19 +2,10 @@ import importlib.metadata import os import sys -import typing +from importlib.metadata import entry_points import wpilib -if sys.version_info < (3, 10): - - def entry_points(group): - eps = importlib.metadata.entry_points() - return eps.get(group, []) - -else: - entry_points = importlib.metadata.entry_points - def _int_env_default(name: str, fallback: int) -> int: value = os.environ.get(name) @@ -83,7 +74,7 @@ def run( self, options: argparse.Namespace, project_path: "os.PathLike[str]", - robot_class: typing.Type[wpilib.RobotBase], + robot_class: type[wpilib.RobotBase], ): if "ws-client" not in self.simexts: print( diff --git a/subprojects/robotpy-telemetry/pyproject.in.toml b/subprojects/robotpy-telemetry/pyproject.in.toml index a06203836..d796d597b 100644 --- a/subprojects/robotpy-telemetry/pyproject.in.toml +++ b/subprojects/robotpy-telemetry/pyproject.in.toml @@ -13,7 +13,7 @@ requires = [ name = "robotpy-telemetry" version = "0.0.0" description = "Binary wrapper for WPILib telemetry library" -requires-python = ">=3.11" +requires-python = ">=3.12" authors = [ {name = "RobotPy Development Team", email = "robotpy@googlegroups.com"}, ] diff --git a/subprojects/robotpy-telemetry/telemetry/mock_backend.py b/subprojects/robotpy-telemetry/telemetry/mock_backend.py index c2f80d82b..81eb8d6cf 100644 --- a/subprojects/robotpy-telemetry/telemetry/mock_backend.py +++ b/subprojects/robotpy-telemetry/telemetry/mock_backend.py @@ -1,7 +1,6 @@ """Value types returned by :class:`telemetry.MockTelemetryBackend`.""" from dataclasses import dataclass, field -from typing import TypeAlias @dataclass @@ -32,7 +31,7 @@ class LogRawValue: type_string: str = "" -ActionValue: TypeAlias = ( +type ActionValue = ( KeepDuplicatesValue | SetPropertyValue | bool diff --git a/subprojects/robotpy-tunables/pyproject.in.toml b/subprojects/robotpy-tunables/pyproject.in.toml index 9dca59314..eb30ebc75 100644 --- a/subprojects/robotpy-tunables/pyproject.in.toml +++ b/subprojects/robotpy-tunables/pyproject.in.toml @@ -13,7 +13,7 @@ requires = [ name = "robotpy-tunables" version = "0.0.0" description = "Binary wrapper for WPILib tunables library" -requires-python = ">=3.11" +requires-python = ">=3.12" authors = [ {name = "RobotPy Development Team", email = "robotpy@googlegroups.com"}, ] diff --git a/subprojects/robotpy-tunables/tests/test_tunable.py b/subprojects/robotpy-tunables/tests/test_tunable.py index 46e237873..8e7af921f 100644 --- a/subprojects/robotpy-tunables/tests/test_tunable.py +++ b/subprojects/robotpy-tunables/tests/test_tunable.py @@ -1,7 +1,6 @@ import array import dataclasses import gc -import inspect import subprocess import sys import weakref diff --git a/subprojects/robotpy-tunables/tunables/__init__.py b/subprojects/robotpy-tunables/tunables/__init__.py index e25acc621..9ae300aed 100644 --- a/subprojects/robotpy-tunables/tunables/__init__.py +++ b/subprojects/robotpy-tunables/tunables/__init__.py @@ -1,8 +1,7 @@ -from . import _init__tunables - from abc import ABC, abstractmethod from collections.abc import Callable -from typing import Generic, TypeVar + +from . import _init__tunables # autogenerated by 'semiwrap create-imports tunables tunables._tunables' # - exclude ComplexTunable @@ -68,10 +67,7 @@ def update_tunables(self) -> None: """ -T = TypeVar("T") - - -class Selectable(ComplexTunable, Generic[T]): +class Selectable[T](ComplexTunable): """Presents a named collection of arbitrary Python objects as a tunable.""" def __init__(self) -> None: diff --git a/subprojects/robotpy-wpilib-drivers/pyproject.in.toml b/subprojects/robotpy-wpilib-drivers/pyproject.in.toml index 809194f8b..497c12b37 100644 --- a/subprojects/robotpy-wpilib-drivers/pyproject.in.toml +++ b/subprojects/robotpy-wpilib-drivers/pyproject.in.toml @@ -13,7 +13,7 @@ requires = [ name = "wpilib-drivers" version = "0.0.0" description = "RobotPy bindings for WPILib third-party drivers" -requires-python = ">=3.11" +requires-python = ">=3.12" authors = [ {name = "RobotPy Development Team", email = "robotpy@googlegroups.com"}, ] diff --git a/subprojects/robotpy-wpilib/pyproject.in.toml b/subprojects/robotpy-wpilib/pyproject.in.toml index bf1632b7e..4589cb806 100644 --- a/subprojects/robotpy-wpilib/pyproject.in.toml +++ b/subprojects/robotpy-wpilib/pyproject.in.toml @@ -18,7 +18,7 @@ requires = [ name = "wpilib" version = "0.0.0" description = "Binary wrapper for WPILib" -requires-python = ">=3.11" +requires-python = ">=3.12" authors = [ {name = "RobotPy Development Team", email = "robotpy@googlegroups.com"}, ] diff --git a/subprojects/robotpy-wpilib/tests/drive/test_mecanum_drive.py b/subprojects/robotpy-wpilib/tests/drive/test_mecanum_drive.py index a1fc4d3ab..f1131e487 100644 --- a/subprojects/robotpy-wpilib/tests/drive/test_mecanum_drive.py +++ b/subprojects/robotpy-wpilib/tests/drive/test_mecanum_drive.py @@ -1,5 +1,3 @@ -import math - import pytest from wpimath import Rotation2d diff --git a/subprojects/robotpy-wpilib/tests/hardware/led/test_led_pattern.py b/subprojects/robotpy-wpilib/tests/hardware/led/test_led_pattern.py index f8c7f71b6..5172c4a2d 100644 --- a/subprojects/robotpy-wpilib/tests/hardware/led/test_led_pattern.py +++ b/subprojects/robotpy-wpilib/tests/hardware/led/test_led_pattern.py @@ -2,7 +2,6 @@ # Open Source Software; you can modify and/or share it under the terms of # the WPILib BSD license file in the root directory of this project. -import math import pytest import wpimath.units as units diff --git a/subprojects/robotpy-wpilib/tests/pytest_plugin_test_helpers.py b/subprojects/robotpy-wpilib/tests/pytest_plugin_test_helpers.py index 0f6558f4d..9a7c4ef65 100644 --- a/subprojects/robotpy-wpilib/tests/pytest_plugin_test_helpers.py +++ b/subprojects/robotpy-wpilib/tests/pytest_plugin_test_helpers.py @@ -1,6 +1,3 @@ -import pathlib - - def _make_robot_module(pytester): pytester.makepyfile(robot_module=""" import wpilib diff --git a/subprojects/robotpy-wpilib/tests/simulation/test_alert_sim.py b/subprojects/robotpy-wpilib/tests/simulation/test_alert_sim.py index 831ae16fc..92e3004c6 100644 --- a/subprojects/robotpy-wpilib/tests/simulation/test_alert_sim.py +++ b/subprojects/robotpy-wpilib/tests/simulation/test_alert_sim.py @@ -16,7 +16,7 @@ def group_name(request): AlertSim.reset_data() -def get_active_alerts(level: Alert.Level) -> T.List[str]: +def get_active_alerts(level: Alert.Level) -> list[str]: return [a.text for a in AlertSim.get_all() if a.level == level and a.is_active()] @@ -31,7 +31,7 @@ def is_alert_active(text: str, level: Alert.Level): def assert_state( level: Alert.Level, - expected_state: T.List[str], + expected_state: list[str], ): assert expected_state == get_active_alerts(level) diff --git a/subprojects/robotpy-wpilib/tests/smartdashboard/test_mechanism2d.py b/subprojects/robotpy-wpilib/tests/smartdashboard/test_mechanism2d.py index cc780cd37..a325b3720 100644 --- a/subprojects/robotpy-wpilib/tests/smartdashboard/test_mechanism2d.py +++ b/subprojects/robotpy-wpilib/tests/smartdashboard/test_mechanism2d.py @@ -2,7 +2,7 @@ import telemetry from ntcore import NetworkTableInstance -from wpilib import Mechanism2d, MechanismLigament2d, MechanismRoot2d +from wpilib import Mechanism2d from wpiutil import Color8Bit diff --git a/subprojects/robotpy-wpilib/wpilib/_impl/cli_sim.py b/subprojects/robotpy-wpilib/wpilib/_impl/cli_sim.py index 9e5e94e22..d03b7b5e8 100644 --- a/subprojects/robotpy-wpilib/wpilib/_impl/cli_sim.py +++ b/subprojects/robotpy-wpilib/wpilib/_impl/cli_sim.py @@ -3,7 +3,6 @@ import importlib.metadata import logging import sys -import typing import wpilib @@ -49,7 +48,7 @@ def run( self, options: argparse.Namespace, nogui: bool, - robot_class: typing.Type[wpilib.RobotBase], + robot_class: type[wpilib.RobotBase], ): if not nogui: try: diff --git a/subprojects/robotpy-wpilib/wpilib/_impl/cli_test.py b/subprojects/robotpy-wpilib/wpilib/_impl/cli_test.py index 3fe3f634b..0859905c3 100644 --- a/subprojects/robotpy-wpilib/wpilib/_impl/cli_test.py +++ b/subprojects/robotpy-wpilib/wpilib/_impl/cli_test.py @@ -5,7 +5,6 @@ import pathlib import sys import tomllib -import typing import wpilib @@ -78,12 +77,12 @@ def run( self, main_file: pathlib.Path, project_path: pathlib.Path, - robot_class: typing.Type[wpilib.RobotBase], + robot_class: type[wpilib.RobotBase], builtin: bool, - isolated: typing.Optional[bool], + isolated: bool | None, coverage_mode: bool, verbose: bool, - pytest_args: typing.List[str], + pytest_args: list[str], jobs: int, ): if isolated is None: @@ -143,12 +142,12 @@ def _run_test( self, main_file: pathlib.Path, project_path: pathlib.Path, - robot_class: typing.Type[wpilib.RobotBase], + robot_class: type[wpilib.RobotBase], builtin: bool, isolated: bool, coverage_mode: bool, verbose: bool, - pytest_args: typing.List[str], + pytest_args: list[str], jobs: int, ): # find test directory, change current directory so pytest can find the tests diff --git a/subprojects/robotpy-wpilib/wpilib/_impl/opmode.py b/subprojects/robotpy-wpilib/wpilib/_impl/opmode.py index cf05c1923..2d2fd3294 100644 --- a/subprojects/robotpy-wpilib/wpilib/_impl/opmode.py +++ b/subprojects/robotpy-wpilib/wpilib/_impl/opmode.py @@ -10,7 +10,7 @@ from pathlib import Path import sys import tokenize -from typing import Any, TypeVar +from typing import TypeVar from hal import RobotMode from wpiutil import Color diff --git a/subprojects/robotpy-wpilib/wpilib/_impl/start.py b/subprojects/robotpy-wpilib/wpilib/_impl/start.py index 6e19f3669..febbf39e5 100644 --- a/subprojects/robotpy-wpilib/wpilib/_impl/start.py +++ b/subprojects/robotpy-wpilib/wpilib/_impl/start.py @@ -1,34 +1,24 @@ -import hal -import wpilib -import wpiutil +import importlib.metadata import logging import os.path import sys import threading import time -import typing - -import importlib.metadata - -if sys.version_info < (3, 10): - - def entry_points(group): - eps = importlib.metadata.entry_points() - return eps.get(group, []) +from importlib.metadata import entry_points -else: - entry_points = importlib.metadata.entry_points +import hal +import wpiutil +import wpilib from .report_error import report_error, report_error_internal -def _log_versions(robotpy_version: typing.Optional[str]): - import wpilib - import wpilib.deployinfo - +def _log_versions(robotpy_version: str | None): import logging + import wpilib.deployinfo + data = wpilib.deployinfo.get_deploy_data() if data: logger = logging.getLogger("deploy-info") @@ -86,7 +76,7 @@ def __init__(self): self._robotpy_version = None @property - def robotpy_version(self) -> typing.Optional[str]: + def robotpy_version(self) -> str | None: if not self._robotpy_version: try: pkg = importlib.metadata.metadata("robotpy") diff --git a/subprojects/robotpy-wpilib/wpilib/cameraserver.py b/subprojects/robotpy-wpilib/wpilib/cameraserver.py index 614947dfa..a68f8d685 100644 --- a/subprojects/robotpy-wpilib/wpilib/cameraserver.py +++ b/subprojects/robotpy-wpilib/wpilib/cameraserver.py @@ -1,5 +1,3 @@ -from typing import Optional - import subprocess import threading import wpiutil @@ -32,7 +30,7 @@ def is_alive(cls) -> bool: return cls._alive @classmethod - def launch(cls, vision_py: Optional[str] = None) -> None: + def launch(cls, vision_py: str | None = None) -> None: """ Launches the CameraServer process in autocapture mode or using a user-specified python script diff --git a/subprojects/robotpy-wpilib/wpilib/deployinfo.py b/subprojects/robotpy-wpilib/wpilib/deployinfo.py index 46909b5d6..42e5f4610 100644 --- a/subprojects/robotpy-wpilib/wpilib/deployinfo.py +++ b/subprojects/robotpy-wpilib/wpilib/deployinfo.py @@ -1,9 +1,8 @@ from ._wpilib import RobotBase import json -import typing -def get_deploy_data() -> typing.Optional[typing.Dict[str, str]]: +def get_deploy_data() -> dict[str, str] | None: """ Utility function useful for retrieving deploy-related information that pyfrc stores with your robot code. The dictionary has the diff --git a/subprojects/robotpy-wpilib/wpilib/opmodes.py b/subprojects/robotpy-wpilib/wpilib/opmodes.py index babe3a1e7..765dd5897 100644 --- a/subprojects/robotpy-wpilib/wpilib/opmodes.py +++ b/subprojects/robotpy-wpilib/wpilib/opmodes.py @@ -1,5 +1,5 @@ from collections.abc import Callable -from typing import Optional, TypeVar, overload +from typing import TypeVar, overload from hal import RobotMode from wpiutil import Color @@ -226,10 +226,10 @@ def add_opmode( opmode_cls: type, mode: RobotMode, name: str, - group: Optional[str] = None, - description: Optional[str] = None, - text_color: Optional[Color] = None, - background_color: Optional[Color] = None, + group: str | None = None, + description: str | None = None, + text_color: Color | None = None, + background_color: Color | None = None, ) -> None: """ Adds an operating mode option. It's necessary to call publish_opmodes() to diff --git a/subprojects/robotpy-wpilib/wpilib/testing/controller.py b/subprojects/robotpy-wpilib/wpilib/testing/controller.py index 0d0838214..dbd8db525 100644 --- a/subprojects/robotpy-wpilib/wpilib/testing/controller.py +++ b/subprojects/robotpy-wpilib/wpilib/testing/controller.py @@ -1,7 +1,6 @@ import contextlib import time import threading -import typing as T import pytest @@ -25,7 +24,7 @@ class RobotTestController: def __init__(self, reraise, robot: RobotBase): self._reraise = reraise - self._thread: T.Optional[threading.Thread] = None + self._thread: threading.Thread | None = None self._robot = robot self._cond = threading.Condition() diff --git a/subprojects/robotpy-wpilib/wpilib/testing/pytest_isolated_tests_plugin.py b/subprojects/robotpy-wpilib/wpilib/testing/pytest_isolated_tests_plugin.py index f6f100108..ca711c4d9 100644 --- a/subprojects/robotpy-wpilib/wpilib/testing/pytest_isolated_tests_plugin.py +++ b/subprojects/robotpy-wpilib/wpilib/testing/pytest_isolated_tests_plugin.py @@ -8,7 +8,6 @@ import signal import sys import time -import typing as T import pytest @@ -214,7 +213,7 @@ class IsolatedTestsPlugin(OpModeTestingPlugin): def __init__( self, - robot_class: T.Type[wpilib.RobotBase], + robot_class: type[wpilib.RobotBase], robot_file: pathlib.Path, builtin_tests: bool, verbose: bool, @@ -375,7 +374,7 @@ def _process_job_messages(self, job: IsolatedTestJob, session: pytest.Session): if not job.conn.poll(): break callname, kwargs = job.conn.recv() - except (IOError, EOFError) as e: + except (OSError, EOFError) as e: job.finished = True break diff --git a/subprojects/robotpy-wpilib/wpilib/testing/pytest_plugin.py b/subprojects/robotpy-wpilib/wpilib/testing/pytest_plugin.py index 13b60de06..214f12f3c 100644 --- a/subprojects/robotpy-wpilib/wpilib/testing/pytest_plugin.py +++ b/subprojects/robotpy-wpilib/wpilib/testing/pytest_plugin.py @@ -1,6 +1,5 @@ import gc import pathlib -import typing as T import weakref import pytest @@ -48,7 +47,7 @@ class RobotTestingPlugin(OpModeTestingPlugin): def __init__( self, - robot_class: T.Type[wpilib.RobotBase], + robot_class: type[wpilib.RobotBase], robot_file: pathlib.Path, isolated: bool, ): diff --git a/subprojects/robotpy-wpilog/pyproject.in.toml b/subprojects/robotpy-wpilog/pyproject.in.toml index 11abd5858..52539c8f1 100644 --- a/subprojects/robotpy-wpilog/pyproject.in.toml +++ b/subprojects/robotpy-wpilog/pyproject.in.toml @@ -12,7 +12,7 @@ requires = [ name = "robotpy-wpilog" version = "0.0.0" description = "Binary wrapper for WPILib logging library" -requires-python = ">=3.11" +requires-python = ">=3.12" authors = [ {name = "RobotPy Development Team", email = "robotpy@googlegroups.com"}, ] diff --git a/subprojects/robotpy-wpimath/pyproject.in.toml b/subprojects/robotpy-wpimath/pyproject.in.toml index cb370d27a..2372f7eaa 100644 --- a/subprojects/robotpy-wpimath/pyproject.in.toml +++ b/subprojects/robotpy-wpimath/pyproject.in.toml @@ -16,7 +16,7 @@ requires = [ name = "robotpy-wpimath" version = "0.0.0" description = "Binary wrapper for WPILib Math library" -requires-python = ">=3.11" +requires-python = ">=3.12" authors = [ {name = "RobotPy Development Team", email = "robotpy@googlegroups.com"}, ] diff --git a/subprojects/robotpy-wpimath/tests/cpp/pyproject.toml b/subprojects/robotpy-wpimath/tests/cpp/pyproject.toml index 2cb890f80..685a206d3 100644 --- a/subprojects/robotpy-wpimath/tests/cpp/pyproject.toml +++ b/subprojects/robotpy-wpimath/tests/cpp/pyproject.toml @@ -8,7 +8,7 @@ requires = [ name = "wpimath_test" version = "0.1" description = "Test project for verifying robotpy-build behavior" -requires-python = ">=3.11" +requires-python = ">=3.12" authors = [ {name = "RobotPy Development Team", email = "robotpy@googlegroups.com"}, ] diff --git a/subprojects/robotpy-wpimath/tests/geometry/test_coordinate_system.py b/subprojects/robotpy-wpimath/tests/geometry/test_coordinate_system.py index aa08a6dac..63b17fefb 100644 --- a/subprojects/robotpy-wpimath/tests/geometry/test_coordinate_system.py +++ b/subprojects/robotpy-wpimath/tests/geometry/test_coordinate_system.py @@ -1,6 +1,3 @@ -import pytest -import math - from wpimath import ( CoordinateSystem, Pose3d, diff --git a/subprojects/robotpy-wpimath/tests/geometry/test_ellipse2d.py b/subprojects/robotpy-wpimath/tests/geometry/test_ellipse2d.py index 0127cd68c..560357c9b 100644 --- a/subprojects/robotpy-wpimath/tests/geometry/test_ellipse2d.py +++ b/subprojects/robotpy-wpimath/tests/geometry/test_ellipse2d.py @@ -1,5 +1,4 @@ import pytest -import math from wpimath import Pose2d, Translation2d, Ellipse2d, Rotation2d diff --git a/subprojects/robotpy-wpimath/tests/geometry/test_pose2d.py b/subprojects/robotpy-wpimath/tests/geometry/test_pose2d.py index ff73c37ee..a09dc0103 100644 --- a/subprojects/robotpy-wpimath/tests/geometry/test_pose2d.py +++ b/subprojects/robotpy-wpimath/tests/geometry/test_pose2d.py @@ -85,23 +85,23 @@ def test_nearest(): origin = Pose2d(x=0, y=0, rotation=Rotation2d.from_degrees(0)) pose1 = Pose2d( - Translation2d(distance=1.0, angle=Rotation2d.from_degrees((45))), + Translation2d(distance=1.0, angle=Rotation2d.from_degrees(45)), Rotation2d.from_degrees(0), ) pose2 = Pose2d( - Translation2d(distance=2.0, angle=Rotation2d.from_degrees((90))), + Translation2d(distance=2.0, angle=Rotation2d.from_degrees(90)), Rotation2d.from_degrees(0), ) pose3 = Pose2d( - Translation2d(distance=3.0, angle=Rotation2d.from_degrees((135))), + Translation2d(distance=3.0, angle=Rotation2d.from_degrees(135)), Rotation2d.from_degrees(0), ) pose4 = Pose2d( - Translation2d(distance=4.0, angle=Rotation2d.from_degrees((180))), + Translation2d(distance=4.0, angle=Rotation2d.from_degrees(180)), Rotation2d.from_degrees(0), ) pose5 = Pose2d( - Translation2d(distance=5.0, angle=Rotation2d.from_degrees((270))), + Translation2d(distance=5.0, angle=Rotation2d.from_degrees(270)), Rotation2d.from_degrees(0), ) diff --git a/subprojects/robotpy-wpimath/tests/geometry/test_pose3d.py b/subprojects/robotpy-wpimath/tests/geometry/test_pose3d.py index e75e0c813..398aa1a4e 100644 --- a/subprojects/robotpy-wpimath/tests/geometry/test_pose3d.py +++ b/subprojects/robotpy-wpimath/tests/geometry/test_pose3d.py @@ -7,9 +7,7 @@ Pose3d, Rotation2d, Rotation3d, - Transform2d, Transform3d, - Translation2d, Translation3d, Quaternion, ) diff --git a/subprojects/robotpy-wpimath/tests/geometry/test_quaternion.py b/subprojects/robotpy-wpimath/tests/geometry/test_quaternion.py index 483b84773..e0488b5ff 100644 --- a/subprojects/robotpy-wpimath/tests/geometry/test_quaternion.py +++ b/subprojects/robotpy-wpimath/tests/geometry/test_quaternion.py @@ -1,7 +1,7 @@ import pytest import math -from wpimath import Quaternion, Rotation3d +from wpimath import Quaternion def test_init(): diff --git a/subprojects/robotpy-wpimath/tests/geometry/test_rectangle2d.py b/subprojects/robotpy-wpimath/tests/geometry/test_rectangle2d.py index eec19963e..37ed2f6c5 100644 --- a/subprojects/robotpy-wpimath/tests/geometry/test_rectangle2d.py +++ b/subprojects/robotpy-wpimath/tests/geometry/test_rectangle2d.py @@ -1,5 +1,4 @@ import pytest -import math from wpimath import Pose2d, Translation2d, Rotation2d, Rectangle2d diff --git a/subprojects/robotpy-wpimath/tests/geometry/test_transform2d.py b/subprojects/robotpy-wpimath/tests/geometry/test_transform2d.py index ea64cd6a3..5bafc7fee 100644 --- a/subprojects/robotpy-wpimath/tests/geometry/test_transform2d.py +++ b/subprojects/robotpy-wpimath/tests/geometry/test_transform2d.py @@ -1,6 +1,3 @@ -import pytest -import math - from wpimath import Rotation2d, Transform2d, Translation2d, Pose2d diff --git a/subprojects/robotpy-wpimath/tests/geometry/test_transform3d.py b/subprojects/robotpy-wpimath/tests/geometry/test_transform3d.py index adf434c21..9d79001fb 100644 --- a/subprojects/robotpy-wpimath/tests/geometry/test_transform3d.py +++ b/subprojects/robotpy-wpimath/tests/geometry/test_transform3d.py @@ -1,4 +1,3 @@ -import pytest import math import numpy as np diff --git a/subprojects/robotpy-wpimath/tests/geometry/test_twist2d.py b/subprojects/robotpy-wpimath/tests/geometry/test_twist2d.py index 6855bd60a..b2d23c89a 100644 --- a/subprojects/robotpy-wpimath/tests/geometry/test_twist2d.py +++ b/subprojects/robotpy-wpimath/tests/geometry/test_twist2d.py @@ -1,7 +1,7 @@ import pytest import math -from wpimath import Twist2d, Pose2d, Rotation2d +from wpimath import Twist2d, Pose2d def test_straight(): diff --git a/subprojects/robotpy-wpimath/tests/kinematics/test_chassis_velocities.py b/subprojects/robotpy-wpimath/tests/kinematics/test_chassis_velocities.py index ccba10332..0f0128c65 100644 --- a/subprojects/robotpy-wpimath/tests/kinematics/test_chassis_velocities.py +++ b/subprojects/robotpy-wpimath/tests/kinematics/test_chassis_velocities.py @@ -1,6 +1,5 @@ import pytest import math -import numpy as np from wpimath import ChassisVelocities, Twist2d, Pose2d, Rotation2d diff --git a/subprojects/robotpy-wpimath/tests/kinematics/test_differential_drive_kinematics.py b/subprojects/robotpy-wpimath/tests/kinematics/test_differential_drive_kinematics.py index 887f87204..aa372f47c 100644 --- a/subprojects/robotpy-wpimath/tests/kinematics/test_differential_drive_kinematics.py +++ b/subprojects/robotpy-wpimath/tests/kinematics/test_differential_drive_kinematics.py @@ -1,12 +1,10 @@ import pytest import math -import numpy as np from wpimath import ( ChassisVelocities, DifferentialDriveKinematics, DifferentialDriveWheelVelocities, - Rotation2d, ) diff --git a/subprojects/robotpy-wpimath/tests/kinematics/test_differential_drive_odometry3d.py b/subprojects/robotpy-wpimath/tests/kinematics/test_differential_drive_odometry3d.py index f6d846afe..f13417053 100644 --- a/subprojects/robotpy-wpimath/tests/kinematics/test_differential_drive_odometry3d.py +++ b/subprojects/robotpy-wpimath/tests/kinematics/test_differential_drive_odometry3d.py @@ -1,7 +1,7 @@ import pytest import math -from wpimath import DifferentialDriveOdometry3d, Rotation3d, Pose3d, Rotation2d +from wpimath import DifferentialDriveOdometry3d, Rotation3d, Pose3d def test_initialize(): diff --git a/subprojects/robotpy-wpimath/tests/kinematics/test_differential_drive_wheel_velocities.py b/subprojects/robotpy-wpimath/tests/kinematics/test_differential_drive_wheel_velocities.py index 9fe74b42e..94866d384 100644 --- a/subprojects/robotpy-wpimath/tests/kinematics/test_differential_drive_wheel_velocities.py +++ b/subprojects/robotpy-wpimath/tests/kinematics/test_differential_drive_wheel_velocities.py @@ -1,5 +1,3 @@ -import pytest - from wpimath import DifferentialDriveWheelVelocities diff --git a/subprojects/robotpy-wpimath/tests/kinematics/test_mecanum_drive_kinematics.py b/subprojects/robotpy-wpimath/tests/kinematics/test_mecanum_drive_kinematics.py index c21d8636d..e1c8a2e72 100644 --- a/subprojects/robotpy-wpimath/tests/kinematics/test_mecanum_drive_kinematics.py +++ b/subprojects/robotpy-wpimath/tests/kinematics/test_mecanum_drive_kinematics.py @@ -6,7 +6,6 @@ ChassisVelocities, MecanumDriveWheelVelocities, MecanumDriveWheelPositions, - Rotation2d, Translation2d, ) diff --git a/subprojects/robotpy-wpimath/tests/kinematics/test_mecanum_drive_odometry.py b/subprojects/robotpy-wpimath/tests/kinematics/test_mecanum_drive_odometry.py index 3f1075b85..e064a9fcf 100644 --- a/subprojects/robotpy-wpimath/tests/kinematics/test_mecanum_drive_odometry.py +++ b/subprojects/robotpy-wpimath/tests/kinematics/test_mecanum_drive_odometry.py @@ -1,5 +1,4 @@ import pytest -import math import random from wpimath import ( diff --git a/subprojects/robotpy-wpimath/tests/kinematics/test_mecanum_drive_odometry3d.py b/subprojects/robotpy-wpimath/tests/kinematics/test_mecanum_drive_odometry3d.py index 65f033ac7..3640177dc 100644 --- a/subprojects/robotpy-wpimath/tests/kinematics/test_mecanum_drive_odometry3d.py +++ b/subprojects/robotpy-wpimath/tests/kinematics/test_mecanum_drive_odometry3d.py @@ -1,5 +1,4 @@ import pytest -import math import random from wpimath import ( diff --git a/subprojects/robotpy-wpimath/tests/kinematics/test_mecanum_drive_wheel_velocities.py b/subprojects/robotpy-wpimath/tests/kinematics/test_mecanum_drive_wheel_velocities.py index 7f20a6a92..92579b2d0 100644 --- a/subprojects/robotpy-wpimath/tests/kinematics/test_mecanum_drive_wheel_velocities.py +++ b/subprojects/robotpy-wpimath/tests/kinematics/test_mecanum_drive_wheel_velocities.py @@ -1,5 +1,3 @@ -import pytest - from wpimath import MecanumDriveWheelVelocities diff --git a/subprojects/robotpy-wpimath/tests/kinematics/test_swerve_drive_odometry.py b/subprojects/robotpy-wpimath/tests/kinematics/test_swerve_drive_odometry.py index e7f91f84d..7337026d5 100644 --- a/subprojects/robotpy-wpimath/tests/kinematics/test_swerve_drive_odometry.py +++ b/subprojects/robotpy-wpimath/tests/kinematics/test_swerve_drive_odometry.py @@ -1,5 +1,4 @@ import pytest -import math import random from wpimath import ( @@ -9,7 +8,6 @@ Rotation2d, SwerveDrive4Kinematics, SwerveDrive4Odometry, - SwerveModuleVelocity, SwerveModulePosition, TrajectoryConfig, Translation2d, diff --git a/subprojects/robotpy-wpimath/tests/kinematics/test_swerve_drive_odometry3d.py b/subprojects/robotpy-wpimath/tests/kinematics/test_swerve_drive_odometry3d.py index 68854ac08..0af53f165 100644 --- a/subprojects/robotpy-wpimath/tests/kinematics/test_swerve_drive_odometry3d.py +++ b/subprojects/robotpy-wpimath/tests/kinematics/test_swerve_drive_odometry3d.py @@ -1,9 +1,7 @@ import pytest -import math import random from wpimath import ( - ChassisVelocities, DrivetrainSplineTrajectoryGenerator, Pose3d, Pose2d, diff --git a/subprojects/robotpy-wpimath/tests/kinematics/test_swerve_module_acceleration.py b/subprojects/robotpy-wpimath/tests/kinematics/test_swerve_module_acceleration.py index 9d2749cb7..ffbd6e4bf 100644 --- a/subprojects/robotpy-wpimath/tests/kinematics/test_swerve_module_acceleration.py +++ b/subprojects/robotpy-wpimath/tests/kinematics/test_swerve_module_acceleration.py @@ -1,5 +1,4 @@ import pytest -import math from wpimath import Rotation2d, SwerveModuleAcceleration from wpimath.units import feet_to_meters diff --git a/subprojects/robotpy-wpimath/tests/kinematics/test_swerve_module_position.py b/subprojects/robotpy-wpimath/tests/kinematics/test_swerve_module_position.py index 66534cbfa..bfd5dfbbd 100644 --- a/subprojects/robotpy-wpimath/tests/kinematics/test_swerve_module_position.py +++ b/subprojects/robotpy-wpimath/tests/kinematics/test_swerve_module_position.py @@ -1,5 +1,3 @@ -import pytest - from wpimath import Rotation2d, SwerveModulePosition diff --git a/subprojects/robotpy-wpimath/tests/test_system.py b/subprojects/robotpy-wpimath/tests/test_system.py index c55b1c8ef..955bb3727 100644 --- a/subprojects/robotpy-wpimath/tests/test_system.py +++ b/subprojects/robotpy-wpimath/tests/test_system.py @@ -2,7 +2,6 @@ import wpimath -import pytest import numpy as np diff --git a/subprojects/robotpy-wpinet/pyproject.in.toml b/subprojects/robotpy-wpinet/pyproject.in.toml index 56a7bcd49..964efc97a 100644 --- a/subprojects/robotpy-wpinet/pyproject.in.toml +++ b/subprojects/robotpy-wpinet/pyproject.in.toml @@ -14,7 +14,7 @@ requires = [ name = "robotpy-wpinet" version = "0.0.0" description = "Binary wrapper for WPILib networking library" -requires-python = ">=3.11" +requires-python = ">=3.12" authors = [ {name = "RobotPy Development Team", email = "robotpy@googlegroups.com"}, ] diff --git a/subprojects/robotpy-wpiutil/pyproject.in.toml b/subprojects/robotpy-wpiutil/pyproject.in.toml index 12da3194d..471a96deb 100644 --- a/subprojects/robotpy-wpiutil/pyproject.in.toml +++ b/subprojects/robotpy-wpiutil/pyproject.in.toml @@ -12,7 +12,7 @@ requires = [ name = "robotpy-wpiutil" version = "0.0.0" description = "Binary wrapper for WPILib utilities library" -requires-python = ">=3.11" +requires-python = ">=3.12" authors = [ {name = "RobotPy Development Team", email = "robotpy@googlegroups.com"}, ] diff --git a/subprojects/robotpy-wpiutil/wpiutil/__init__.py b/subprojects/robotpy-wpiutil/wpiutil/__init__.py index b9d20c8ce..122071c80 100644 --- a/subprojects/robotpy-wpiutil/wpiutil/__init__.py +++ b/subprojects/robotpy-wpiutil/wpiutil/__init__.py @@ -36,9 +36,7 @@ ] # Imported for side effects only -from . import _stacktrace +from . import _stacktrace # noqa: F401 # Type alias -import typing - -json = typing.Union[None, bool, int, float, str, typing.List, typing.Dict] +type json = bool | int | float | str | list | dict | None diff --git a/subprojects/robotpy-wpiutil/wpiutil/wpistruct/dataclass.py b/subprojects/robotpy-wpiutil/wpiutil/wpistruct/dataclass.py index 85b999942..6a24b09a7 100644 --- a/subprojects/robotpy-wpiutil/wpiutil/wpistruct/dataclass.py +++ b/subprojects/robotpy-wpiutil/wpiutil/wpistruct/dataclass.py @@ -39,7 +39,7 @@ class double(float): pass # fmt: on -def make_wpistruct(cls=None, /, *, name: typing.Optional[str] = None): +def make_wpistruct(cls=None, /, *, name: str | None = None): """ This decorator allows you to easily define a custom type that can be used with wpilib's custom serialization protocol (for use in datalog @@ -118,7 +118,7 @@ def _get_fixed_tuple_array_info(cls_name: str, field_name: str, ftype: type): return element_type, len(args) -def _process_class(cls, struct_name: typing.Optional[str]): +def _process_class(cls, struct_name: str | None): resolved_hints = typing.get_type_hints(cls) field_names = [field.name for field in dataclasses.fields(cls)] resolved_field_types = {name: resolved_hints[name] for name in field_names} @@ -144,7 +144,7 @@ def _process_class(cls, struct_name: typing.Optional[str]): # unpack_intos = [] for_each_nested = [] - ctx: typing.Dict[str, typing.Any] = {"cls": cls} + ctx: dict[str, typing.Any] = {"cls": cls} for field_idx, (name, ftype) in enumerate(resolved_field_types.items()): if ftype in _type_to_fmt: diff --git a/subprojects/robotpy-wpiutil/wpiutil/wpistruct/desc.py b/subprojects/robotpy-wpiutil/wpiutil/wpistruct/desc.py index fed6a4f53..e53d83529 100644 --- a/subprojects/robotpy-wpiutil/wpiutil/wpistruct/desc.py +++ b/subprojects/robotpy-wpiutil/wpiutil/wpistruct/desc.py @@ -1,10 +1,5 @@ import typing - -if typing.TYPE_CHECKING: - from typing_extensions import Buffer -else: - # Avoiding typing_extensions runtime dependency - Buffer = bytearray +from collections.abc import Buffer, Callable class StructDescriptor(typing.NamedTuple): @@ -30,19 +25,17 @@ class StructDescriptor(typing.NamedTuple): size: int #: A function that converts the type to bytes - pack: typing.Callable[[typing.Any], bytes] + pack: Callable[[typing.Any], bytes] #: A function that converts the type to bytes - pack_into: typing.Callable[[typing.Any, Buffer], None] + pack_into: Callable[[typing.Any, Buffer], None] #: A function that converts bytes to an instance - unpack: typing.Callable[[Buffer], typing.Any] + unpack: Callable[[Buffer], typing.Any] #: A function that updates the given instance using the deserialized bytes #: .. not supported - # unpack_into: typing.Callable[[typing.Any, Buffer], None] + # unpack_into: Callable[[typing.Any, Buffer], None] #: If this contains nested structs, calls wpiutil.wpistruct.for_each_nested for each - for_each_nested: typing.Optional[ - typing.Callable[[typing.Callable[[str, str], None]], None] - ] + for_each_nested: Callable[[Callable[[str, str], None]], None] | None diff --git a/subprojects/robotpy-xrp/pyproject.in.toml b/subprojects/robotpy-xrp/pyproject.in.toml index ca4fa1944..2b9dae37d 100644 --- a/subprojects/robotpy-xrp/pyproject.in.toml +++ b/subprojects/robotpy-xrp/pyproject.in.toml @@ -14,7 +14,7 @@ requires = [ name = "robotpy-xrp" version = "0.0.0" description = "Binary wrapper for WPILib XRP Vendor library" -requires-python = ">=3.11" +requires-python = ">=3.12" authors = [ {name = "RobotPy Development Team", email = "robotpy@googlegroups.com"}, ] diff --git a/subprojects/robotpy-xrp/xrp/cli.py b/subprojects/robotpy-xrp/xrp/cli.py index bb65cbfde..5afeb8e2e 100644 --- a/subprojects/robotpy-xrp/xrp/cli.py +++ b/subprojects/robotpy-xrp/xrp/cli.py @@ -2,19 +2,10 @@ import importlib.metadata import os import sys -import typing +from importlib.metadata import entry_points import wpilib -if sys.version_info < (3, 10): - - def entry_points(group): - eps = importlib.metadata.entry_points() - return eps.get(group, []) - -else: - entry_points = importlib.metadata.entry_points - def _int_env_default(name: str, fallback: int) -> int: value = os.environ.get(name) @@ -83,7 +74,7 @@ def run( self, options: argparse.Namespace, project_path: "os.PathLike[str]", - robot_class: typing.Type[wpilib.RobotBase], + robot_class: type[wpilib.RobotBase], ): if "xrp" not in self.simexts: print(