lots more refactoring

This commit is contained in:
Jan Petykiewicz 2026-03-30 19:51:37 -07:00
commit bc218a416b
43 changed files with 1433 additions and 1694 deletions

48
inire/seeds.py Normal file
View file

@ -0,0 +1,48 @@
from __future__ import annotations
from dataclasses import dataclass
from typing import Literal
BendDirection = Literal["CW", "CCW"]
@dataclass(frozen=True, slots=True)
class StraightSeed:
length: float
def __post_init__(self) -> None:
object.__setattr__(self, "length", float(self.length))
@dataclass(frozen=True, slots=True)
class Bend90Seed:
radius: float
direction: BendDirection
def __post_init__(self) -> None:
object.__setattr__(self, "radius", float(self.radius))
@dataclass(frozen=True, slots=True)
class SBendSeed:
offset: float
radius: float
def __post_init__(self) -> None:
object.__setattr__(self, "offset", float(self.offset))
object.__setattr__(self, "radius", float(self.radius))
PathSegmentSeed = StraightSeed | Bend90Seed | SBendSeed
@dataclass(frozen=True, slots=True)
class PathSeed:
segments: tuple[PathSegmentSeed, ...]
def __post_init__(self) -> None:
segments = tuple(self.segments)
if any(not isinstance(segment, StraightSeed | Bend90Seed | SBendSeed) for segment in segments):
raise TypeError("PathSeed segments must be StraightSeed, Bend90Seed, or SBendSeed instances")
object.__setattr__(self, "segments", segments)