Skip to content

chore(linter): ensure motors module passes MyPy type checks#2939

Merged
s1lent4gnt merged 11 commits intomainfrom
pr/2732
Feb 10, 2026
Merged

chore(linter): ensure motors module passes MyPy type checks#2939
s1lent4gnt merged 11 commits intomainfrom
pr/2732

Conversation

@imstevenpmwork
Copy link
Collaborator

@imstevenpmwork imstevenpmwork commented Feb 9, 2026

Supersedes #2732

yurekami and others added 8 commits December 29, 2025 18:35
This commit fixes 62 mypy type errors in the motors module by:

- Updating Protocol classes (PortHandler, PacketHandler, GroupSyncRead,
  GroupSyncWrite) to use class-level attribute declarations instead of
  __init__ body declarations
- Adding missing `broadcastPing` method to PacketHandler Protocol
- Fixing return type annotations (e.g., `_get_motor_model` returns str, not int)
- Fixing parameter types to use `Sequence` for covariant list parameters
- Fixing `Mapping` for covariant dict value types in `_normalize`
- Updating method signatures to be consistent across parent and child classes
  (disable_torque, enable_torque, _get_half_turn_homings)
- Adding explicit `int()` casts for MotorCalibration arguments
- Adding explicit `return None` for functions returning Optional types
- Adding type annotations for variables like `data_list: dict[int, int]`
- Using `# type: ignore[method-assign]` for intentional monkeypatch
- Fixing variable references (using `self.groups` instead of `groups`)

Fixes #1723

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@imstevenpmwork imstevenpmwork changed the title Pr/2732 chore(linter): ensure motors module passes MyPy type checks Feb 9, 2026
@imstevenpmwork imstevenpmwork self-assigned this Feb 9, 2026
@github-actions github-actions bot added the robots Issues concerning robots HW interfaces label Feb 9, 2026
Copy link
Member

@s1lent4gnt s1lent4gnt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_get_half_turn_homings should be like this:

    @abc.abstractmethod
    def _get_half_turn_homings(self, positions: dict[str, Value]) -> dict[str, Value]:
        pass

Copy link
Member

@s1lent4gnt s1lent4gnt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, LGTM!

@s1lent4gnt s1lent4gnt merged commit 35363c5 into main Feb 10, 2026
18 of 19 checks passed
@s1lent4gnt s1lent4gnt deleted the pr/2732 branch February 10, 2026 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

robots Issues concerning robots HW interfaces

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants