Whole file

hongdangmoo49/Trinity

The author described this change as fix(tui): address code quality review for SacredGeometryAnimator. It counts as a record because the checks below fail on the code as it stood at 3c545dc82 and pass on 39c942aa2, with nothing else changed between the two runs.

Fix saved2026-06-05
Sharing licenceMIT · LICENSE
Change size+10 5

What the code was meant to do, written into the code itself as a save note

fix(tui): address code quality review for SacredGeometryAnimator

The change

77 from __future__ import annotations
88
99 import math
10-from dataclasses import dataclass, field
10+from dataclasses import dataclass
1111
1212
1313 @dataclass(frozen=True)
1515 """Character palette for a given render mode."""
1616
1717 circle: str
18- diamond: str
1918 vline: str
2019 bslash: str
2120 fslash: str
2928 _GLYPH_MODES: dict[str, _GlyphSet] = {
3029 "modern": _GlyphSet(
3130 circle="○",
32- diamond="◆",
3331 vline="│",
3432 bslash="╲",
3533 fslash="╱",
4139 ),
4240 "unicode": _GlyphSet(
4341 circle="○",
44- diamond="◆",
4542 vline="│",
4643 bslash="╲",
4744 fslash="╱",
5350 ),
5451 "ascii": _GlyphSet(
5552 circle="o",
56- diamond="+",
5753 vline="|",
5854 bslash="\\",
5955 fslash="/",
8682 """
8783
8884 def __init__(self, width: int = 40, height: int = 13, mode: str = "modern") -> None:
85+ if width < 1 or height < 1:
86+ raise ValueError(f"Dimensions must be >= 1, got width={width}, height={height}")
87+ if mode not in _GLYPH_MODES:
88+ raise ValueError(f"Unsupported render mode: {mode!r}. Valid modes: {sorted(_GLYPH_MODES)}")
8989 self._width = width
9090 self._height = height
9191 self._mode = mode
151151
152152 Args:
153153 mode: One of ``"modern"``, ``"unicode"``, or ``"ascii"``.
154+
155+ Raises:
156+ ValueError: If *mode* is not a recognised glyph mode.
154157 """
158+ if mode not in _GLYPH_MODES:
159+ raise ValueError(f"Unsupported render mode: {mode!r}. Valid modes: {sorted(_GLYPH_MODES)}")
155160 self._mode = mode
156161 self._glyphs = _GLYPH_MODES[mode]
157162

The check that tells the two apart

failpass·tests/test_tui_sacred_geometry.py::test_animator_rejects_invalid_mode
failpass·tests/test_tui_sacred_geometry.py::test_animator_rejects_zero_dimensions
failpass·tests/test_tui_sacred_geometry.py::test_animator_update_mode_rejects_invalid

Check file tests/test_tui_sacred_geometry.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before it3c545dc824e14f1690232240daa3e657c4488572
Broken version dated2026-06-05
Moduletrinity.tui.sacred_geometry
Units changedSacredGeometryAnimator, _GlyphSet
Fingerprint3c98f09e98f2971b
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.

Other bugs found in hongdangmoo49/Trinity