Skip to content

Unreachable branch in _muted_line_theme, and a muting test that cannot detect a broken constant #1904

Description

@pinin4fjords

Two small defects in the inactive-line muting code, both found while reviewing PR #1888.

An unreachable branch in _muted_line_theme

src/nf_metro/render/svg.py builds the muted override theme two ways: a FrozenRecord rebuild (around :3988) because a FrozenRecord cannot be dataclasses.replace-d, and a dataclasses.replace() call (around :3999) for a plain Theme.

RenderPlan.theme is typed FrozenRecord, and _emit_render_plan does theme = plan.theme, so every render takes the FrozenRecord branch. The replace() branch is unreachable from any render path (it exists to satisfy the Theme parameter annotation) and has no test coverage. Verified by instrumenting the function during a real render_string: one call, frozen=True.

Either drop the branch and narrow the annotation to what callers actually pass, or keep it and cover it. Leaving an untested unreachable branch in the muting path is how the original terminus_font_color defect stayed hidden.

A test that could pass with the feature broken

tests/test_inactive_lines.py, in the terminus-label test added by PR #1888, asserts the active case against the imported constant:

assert _icon_label_fill(svg, "b_out", "BAM") == TERMINUS_FONT_COLOR

If someone set TERMINUS_FONT_COLOR = "#888888", both the active and the muted assertion would pass while the feature rendered meaningless. A literal "#000000", or an added assertion that the active and muted fills differ, closes it.

Neither is release-blocking. See also #1894 (muted labels defeated by the chrome CSS) and #1895 (elements that do not mute at all).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority:lowFew/no arms unblocked, niche mode, or latentrefactorCode restructuring without behavior changerenderSVG generation, themes, legend, icons (render/)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions