Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Don't use Any type in API #32

@codekansas

Description

@codekansas

We should use proper typing for the user-facing API commands, like this:

    def command_actuators(self, commands: List[Dict[str, Any]]) -> List[common_pb2.ActionResult]: ...

Instead of having Any type (which makes it hard to remember what commands to provide) we should use a TypedDict

from typing import TypedDict, NotRequired

class ActuatorCommand(TypedDict):
    actuator_id: int
    position: NotRequired[float]
    velocity: NotRequired[float]
    torque: NotRequired[float]

...

    def command_actuators(self, commands: List[ActuatorCommand]) -> List[common_pb2.ActionResult]: ...

We need to do this for the entire API.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Locked

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions