diff --git a/.github/workflows/dist.yml b/.github/workflows/dist.yml index fc3d05b1..b71c239e 100644 --- a/.github/workflows/dist.yml +++ b/.github/workflows/dist.yml @@ -11,9 +11,24 @@ on: jobs: ci: - uses: robotpy/build-actions/.github/workflows/package-pure.yml@v2024-alpha + uses: robotpy/build-actions/.github/workflows/package-pure.yml@v2024 with: enable_sphinx_check: false secrets: META_REPO_ACCESS_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }} PYPI_API_TOKEN: ${{ secrets.PYPI_PASSWORD }} + + check-mypy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: "3.12" + - name: Install requirements + run: | + pip --disable-pip-version-check install mypy setuptools wheel setuptools_scm + pip --disable-pip-version-check install --no-build-isolation -e . + - name: Run mypy + run: | + mypy commands2 \ No newline at end of file diff --git a/commands2/button/commandjoystick.py b/commands2/button/commandjoystick.py index cdb84340..f5f28c51 100644 --- a/commands2/button/commandjoystick.py +++ b/commands2/button/commandjoystick.py @@ -13,6 +13,8 @@ class CommandJoystick(CommandGenericHID): A version of Joystick with Trigger factories for command-based. """ + _hid: Joystick + def __init__(self, port: int): """ Construct an instance of a controller. diff --git a/commands2/button/commandps4controller.py b/commands2/button/commandps4controller.py index 567ecf33..9b2da01d 100644 --- a/commands2/button/commandps4controller.py +++ b/commands2/button/commandps4controller.py @@ -13,6 +13,8 @@ class CommandPS4Controller(CommandGenericHID): A version of PS4Controller with Trigger factories for command-based. """ + _hid: PS4Controller + def __init__(self, port: int): """ Construct an instance of a device. diff --git a/commands2/button/commandxboxcontroller.py b/commands2/button/commandxboxcontroller.py index 50428d2d..2c613f4b 100644 --- a/commands2/button/commandxboxcontroller.py +++ b/commands2/button/commandxboxcontroller.py @@ -13,6 +13,8 @@ class CommandXboxController(CommandGenericHID): A version of XboxController with Trigger factories for command-based. """ + _hid: XboxController + def __init__(self, port: int): """ Construct an instance of a controller. diff --git a/commands2/command.py b/commands2/command.py index 39afad12..e8b0546f 100644 --- a/commands2/command.py +++ b/commands2/command.py @@ -6,7 +6,7 @@ from enum import Enum from typing import TYPE_CHECKING, Any, Callable, Set -from typing_extensions import Self +from typing_extensions import Self, TypeAlias if TYPE_CHECKING: from .instantcommand import InstantCommand @@ -54,7 +54,9 @@ class Command(Sendable): This class is provided by the NewCommands VendorDep """ - InterruptionBehavior = InterruptionBehavior # type alias for 2023 location + InterruptionBehavior: TypeAlias = ( + InterruptionBehavior # type alias for 2023 location + ) requirements: Set[Subsystem] @@ -62,9 +64,9 @@ def __new__(cls, *args, **kwargs) -> Self: instance = super().__new__( cls, ) - instance.requirements = set() - SendableRegistry.add(instance, cls.__name__) super().__init__(instance) + SendableRegistry.add(instance, cls.__name__) + instance.requirements = set() return instance def __init__(self): diff --git a/commands2/commandscheduler.py b/commands2/commandscheduler.py index fa7b41e7..ef51150c 100644 --- a/commands2/commandscheduler.py +++ b/commands2/commandscheduler.py @@ -21,9 +21,9 @@ class CommandScheduler: methods to be called and for their default commands to be scheduled. """ - _instance: Optional[Self] = None + _instance: Optional[CommandScheduler] = None - def __new__(cls) -> Self: + def __new__(cls) -> CommandScheduler: if cls._instance is None: return super().__new__(cls) return cls._instance diff --git a/commands2/util.py b/commands2/util.py index d60da8c2..617a5762 100644 --- a/commands2/util.py +++ b/commands2/util.py @@ -1,14 +1,14 @@ from __future__ import annotations -from typing import Iterable, Tuple, Union +from typing import Iterable, List, Tuple, Union from .command import Command def flatten_args_commands( *commands: Union[Command, Iterable[Command]] -) -> Tuple[Command]: - flattened_commands = [] +) -> Tuple[Command, ...]: + flattened_commands: List[Command] = [] for command in commands: if isinstance(command, Command): flattened_commands.append(command) diff --git a/commands2/wrappercommand.py b/commands2/wrappercommand.py index c61ffe60..43c50372 100644 --- a/commands2/wrappercommand.py +++ b/commands2/wrappercommand.py @@ -26,6 +26,7 @@ def __init__(self, command: Command): CommandScheduler.getInstance().registerComposedCommands([command]) self._command = command + self.setName(self._command.getName()) def initialize(self): """The initial subroutine of a command. Called once when the command is initially scheduled."""