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 <noreply@anthropic.com>
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user