Skip to content

Create unified Instruction protocol and fix inheritance #58

@TravisBumgarner

Description

@TravisBumgarner

Description

Several instruction classes don't properly inherit from a base class, breaking type inference:

  • InstructionFeedRate has no parent class
  • Instruction3DPrinterPlottingHeight has no parent class
  • Instruction3DPrinterNavigationHeight has no parent class

Create a Protocol that all instruction classes implement, ensuring consistent interface.

Proposed Changes

Add to instruction module:

from typing import Protocol

class Instruction(Protocol):
    def to_g_code(self) -> str: ...
    def __str__(self) -> str: ...

Ensure all instruction classes either:

  1. Inherit from a common base class, OR
  2. Implement the Protocol interface

Acceptance Criteria

  • Create Instruction protocol in instruction module
  • InstructionFeedRate implements the protocol (add _BaseInstruction inheritance or ensure protocol compliance)
  • Instruction3DPrinterPlottingHeight implements the protocol
  • Instruction3DPrinterNavigationHeight implements the protocol
  • Update TInstructionUnion type in _Layer.py to use the protocol
  • All existing tests pass
  • mypy passes with no new errors

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions