fix: add defensive exhaustive branches to enum matches
This commit is contained in:
1 parent
7f00fc9d18
commit
e2c15f7145
4 files changed
+10
-2
No files matched your search
@@ -16,6 +16,8 @@ class CliSvgRenderKind(enum.StrEnum):
|
||||
return SvgRenderKind.Inkscape
|
||||
case CliSvgRenderKind.ReSvg:
|
||||
return SvgRenderKind.ReSvg
|
||||
case _:
|
||||
raise ValueError(f"Unknown CLI-specific SVG render kind: {self}")
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
|
||||
@@ -345,8 +345,8 @@ class Environment(Generic[P]):
|
||||
filename = f"{name}.{kind}.scale-{scale}.png"
|
||||
elif targetsize is not None:
|
||||
check_msix_targetsize(targetsize)
|
||||
# TODO: This altform code are ugly (do not utilize enum.StrEnum)
|
||||
# May be improved in future.
|
||||
# TODO: These altform generation code are shit
|
||||
# (doesn't utilize enum.StrEnum). May be improved in future.
|
||||
altform: Optional[str]
|
||||
match plated:
|
||||
case MsixAppPlatedKind.Plated:
|
||||
|
||||
@@ -31,6 +31,8 @@ def anchor_to_offset(
|
||||
x = oversize_width // 2
|
||||
case HorizontalAnchor.Right:
|
||||
x = oversize_width
|
||||
case _:
|
||||
raise ValueError(f"Unknown horizontal anchor: {horizontal_anchor}")
|
||||
|
||||
y: int
|
||||
match vertical_anchor:
|
||||
@@ -40,6 +42,8 @@ def anchor_to_offset(
|
||||
y = oversize_height // 2
|
||||
case VerticalAnchor.Bottom:
|
||||
y = oversize_height
|
||||
case _:
|
||||
raise ValueError(f"Unknown vertical anchor: {vertical_anchor}")
|
||||
|
||||
return Point(x, y)
|
||||
|
||||
|
||||
@@ -83,6 +83,8 @@ def render_svg(src: Path, dst: Path, kind: SvgRenderKind, cfg: SvgConfig) -> Non
|
||||
str(src),
|
||||
str(dst),
|
||||
]
|
||||
case _:
|
||||
raise ValueError(f"Unknown SVG render kind: {kind}")
|
||||
|
||||
proc = subprocess.run(cmd, capture_output=False)
|
||||
if proc.returncode != 0:
|
||||
|
||||
Reference in new issue
Block a user