Skip to content

Refactor grid simulation action dispatch for type safety #9

Description

@williamzujkowski

adapters/simulation/grid.py stores action handlers in a class-level dict _action_handlers: dict[ActionType, object] containing the raw unbound method functions, invoked via handler(self, action). This works and is covered by tests, but the object typing defeats type checking on the call, and ruff flags it (RUF012 mutable-class-default).

Suggested fix: build the handler map in init binding the methods ({ActionType.MOVE: self._handle_move, ...}) with a typed Callable[[Action], ActionResult] signature, or annotate as ClassVar. This restores type safety and removes the lint violation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions