From 733b4dd9ecc0200ad968eaf6c9658166d6ee0279 Mon Sep 17 00:00:00 2001 From: Gene Johnson Date: Thu, 19 Mar 2026 11:09:46 -0700 Subject: [PATCH] style: apply ruff lint fixes and formatting to figment modules Fixes: unused imports, import sorting, unused variable, overly broad exception type in test. Co-Authored-By: Claude Opus 4.6 --- effects_plugins/figment.py | 18 ++++++++++++++---- engine/layers.py | 8 ++------ engine/scroll.py | 2 +- tests/test_figment.py | 10 +--------- tests/test_figment_render.py | 3 ++- 5 files changed, 20 insertions(+), 21 deletions(-) diff --git a/effects_plugins/figment.py b/effects_plugins/figment.py index af10002..bf9ca14 100644 --- a/effects_plugins/figment.py +++ b/effects_plugins/figment.py @@ -53,7 +53,11 @@ class FigmentEffect(EffectPlugin): }, ) - def __init__(self, figment_dir: str | None = None, triggers: list[FigmentTrigger] | None = None): + def __init__( + self, + figment_dir: str | None = None, + triggers: list[FigmentTrigger] | None = None, + ): self.config = EffectConfig( enabled=False, intensity=1.0, @@ -125,7 +129,9 @@ class FigmentEffect(EffectPlugin): self._phase = FigmentPhase.REVEAL self._progress = 0.0 - def get_figment_state(self, frame_number: int, w: int, h: int) -> FigmentState | None: + def get_figment_state( + self, frame_number: int, w: int, h: int + ) -> FigmentState | None: """Tick the state machine and return current state, or None if idle.""" if not self.config.enabled: return None @@ -178,9 +184,13 @@ class FigmentEffect(EffectPlugin): def _handle_command(self, cmd: FigmentCommand, w: int, h: int) -> None: if cmd.action == FigmentAction.TRIGGER: self.trigger(w, h) - elif cmd.action == FigmentAction.SET_INTENSITY and isinstance(cmd.value, (int, float)): + elif cmd.action == FigmentAction.SET_INTENSITY and isinstance( + cmd.value, (int, float) + ): self.config.intensity = float(cmd.value) - elif cmd.action == FigmentAction.SET_INTERVAL and isinstance(cmd.value, (int, float)): + elif cmd.action == FigmentAction.SET_INTERVAL and isinstance( + cmd.value, (int, float) + ): self.config.params["interval_secs"] = float(cmd.value) elif cmd.action == FigmentAction.SET_COLOR and isinstance(cmd.value, str): if cmd.value in THEME_REGISTRY: diff --git a/engine/layers.py b/engine/layers.py index 4997c82..a3cc0d5 100644 --- a/engine/layers.py +++ b/engine/layers.py @@ -57,9 +57,7 @@ def render_message_overlay( else: msg_rows = msg_cache[1] - msg_rows = msg_gradient( - msg_rows, (time.monotonic() * config.GRAD_SPEED) % 1.0 - ) + msg_rows = msg_gradient(msg_rows, (time.monotonic() * config.GRAD_SPEED) % 1.0) elapsed_s = int(time.monotonic() - m_ts) remaining = max(0, config.MESSAGE_DISPLAY_SECS - elapsed_s) @@ -353,8 +351,6 @@ def render_figment_overlay( if has_content: line_str = "".join(line_buf).rstrip() if line_str.strip(): - overlay.append( - f"\033[{scr_row};{center_col + 1}H{line_str}{RST}" - ) + overlay.append(f"\033[{scr_row};{center_col + 1}H{line_str}{RST}") return overlay diff --git a/engine/scroll.py b/engine/scroll.py index a58669e..d297b3d 100644 --- a/engine/scroll.py +++ b/engine/scroll.py @@ -18,8 +18,8 @@ from engine.frame import calculate_scroll_step from engine.layers import ( apply_glitch, process_effects, - render_firehose, render_figment_overlay, + render_firehose, render_message_overlay, render_ticker_zone, ) diff --git a/tests/test_figment.py b/tests/test_figment.py index b17116a..2f581d1 100644 --- a/tests/test_figment.py +++ b/tests/test_figment.py @@ -2,17 +2,11 @@ import os from enum import Enum -from unittest.mock import patch - -import pytest from effects_plugins.figment import FigmentEffect, FigmentPhase, FigmentState from engine.effects.types import EffectConfig, EffectContext - -FIXTURE_SVG = os.path.join( - os.path.dirname(__file__), "fixtures", "test.svg" -) +FIXTURE_SVG = os.path.join(os.path.dirname(__file__), "fixtures", "test.svg") FIGMENTS_DIR = os.path.join(os.path.dirname(__file__), "fixtures") @@ -104,12 +98,10 @@ class TestFigmentStateMachine: assert state.phase == FigmentPhase.REVEAL # Advance enough frames to get through all phases - last_state = None for frame in range(2, 100): state = effect.get_figment_state(frame, 40, 20) if state is None: break - last_state = state # Should have completed the full cycle back to idle assert state is None diff --git a/tests/test_figment_render.py b/tests/test_figment_render.py index 4b95acf..31f47ad 100644 --- a/tests/test_figment_render.py +++ b/tests/test_figment_render.py @@ -31,7 +31,8 @@ class TestRasterizeSvg: def test_nonexistent_file_raises(self): import pytest - with pytest.raises(Exception): + + with pytest.raises((FileNotFoundError, OSError)): rasterize_svg("/nonexistent/file.svg", 40, 20)