Skip to content

Add mypy checking to CI #31

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion .github/workflows/dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions commands2/button/commandjoystick.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions commands2/button/commandps4controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions commands2/button/commandxboxcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 6 additions & 4 deletions commands2/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -54,17 +54,19 @@ 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]

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):
Expand Down
4 changes: 2 additions & 2 deletions commands2/commandscheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions commands2/util.py
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
1 change: 1 addition & 0 deletions commands2/wrappercommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down