-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Milestone
Description
Description
After consolidating instructions, convert them to dataclasses for cleaner definitions and automatic __init__, __repr__, etc.
Current Pattern
class InstructionPoint(_BaseInstruction):
def __init__(self, feed_rate: float, x: float, y: float):
self.x = x
self.y = y
self.feed_rate = feed_rate
if x is None or y is None:
raise ValueError("Point requires an X or Y")
def __str__(self) -> str:
return f"Point: ({self.x}, {self.y})"
def to_g_code(self) -> str:
return f"G1 X{self.x:.3f} Y{self.y:.3f} F{self.feed_rate}"Proposed Pattern
@dataclass
class PointInstruction(Instruction):
x: float
y: float
feed_rate: float
def __post_init__(self) -> None:
if self.x is None or self.y is None:
raise ValueError("Point requires an X and Y")
def to_g_code(self) -> str:
return f"G1 X{self.x:.3f} Y{self.y:.3f} F{self.feed_rate}"Acceptance Criteria
- All instruction classes converted to dataclasses
- Remove redundant
__str__methods where not needed - Validation moved to
__post_init__where applicable - All existing tests pass
- mypy passes
Dependencies
- Depends on Consolidate instruction classes into single module #61 (instruction consolidation)
Metadata
Metadata
Assignees
Labels
No labels