Skip to content

fix(typing): add missing @classmethod to SE3.Eul, SE3.RPY, SE3.Trans overloads - #283

Open
filipjsowa wants to merge 1 commit into
rai-opensource:masterfrom
filipjsowa:fix/se3-overload-classmethod
Open

filipjsowa wants to merge 1 commit into
rai-opensource:masterfrom
filipjsowa:fix/se3-overload-classmethod

Conversation

@filipjsowa

Copy link
Copy Markdown

The @overload stubs for SE3.Eul, SE3.RPY and SE3.Trans lacked @classmethod (only the implementations had it), so type checkers bound the first call argument to cls and flagged valid calls as errors:

from spatialmath import SE3
SE3.Trans(0, 0, 0.1)
SE3.Eul(0.1, 0.2, 0.3)
error: No overloads for "Trans" match the provided arguments
  Argument types: (Literal[0], Literal[0], float)
error: Argument of type "float" cannot be assigned to parameter "cls" of type "SE3" in function "Eul"

This shows up in VS Code by default, since Pylance uses Pyright. This adds @classmethod under each @overload, matching the order already used by SO3.Eul / SO3.RPY.

Checked with pyright on a file calling each overload (Trans(x, y, z), Trans([x, y, z]), Eul/RPY with scalars and a list): 10 errors before, 0 after, and SE3.Trans(...) is now inferred as SE3 instead of Unknown. There's no runtime change, because overload stubs are discarded at definition time. No test added, since CI doesn't run a type checker yet (#143).

🤖 Generated with Claude Code

…overloads

The @overload stubs for these classmethods were declared without
@classmethod, so type checkers (Pyright/Pylance, mypy) bound the first
call argument to cls and reported valid calls such as
SE3.Trans(0, 0, 0.1) as errors. Match the ordering already used by
SO3.Eul/SO3.RPY (@overload then @classmethod).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant