From e034da3d20ebe386a3f9aa82f3f429f7c940267c Mon Sep 17 00:00:00 2001 From: vegu-ai-tools <152010387+vegu-ai-tools@users.noreply.github.com> Date: Tue, 31 Mar 2026 19:09:32 +0300 Subject: [PATCH] linting --- src/talemate/agents/director/plan/mixin.py | 16 ++++----- .../baselines/test_director_baselines.py | 35 +++++++++++++++---- tests/test_plan_expand.py | 5 ++- 3 files changed, 36 insertions(+), 20 deletions(-) diff --git a/src/talemate/agents/director/plan/mixin.py b/src/talemate/agents/director/plan/mixin.py index d8a252d0..08607409 100644 --- a/src/talemate/agents/director/plan/mixin.py +++ b/src/talemate/agents/director/plan/mixin.py @@ -99,9 +99,7 @@ class PlanMixin: async def _plan_revise_narrator_content(self, narrator, content: str) -> str: """Send narrator generated signal so automatic revision can process the content.""" emission = NarratorAgentEmission(agent=narrator, response=content) - await talemate.emit.async_signals.get("agent.narrator.generated").send( - emission - ) + await talemate.emit.async_signals.get("agent.narrator.generated").send(emission) return emission.response async def _plan_push_and_emit_block(self, scene, block: dict, narrator) -> int: @@ -153,7 +151,9 @@ class PlanMixin: revised = extracted.get("response", []) if not revised: - log.warning("expand.critique.no_blocks_returned", fallback="using originals") + log.warning( + "expand.critique.no_blocks_returned", fallback="using originals" + ) return blocks log.info("expand.critique.done", original=len(blocks), revised=len(revised)) @@ -239,18 +239,14 @@ class PlanMixin: blocks = extracted.get("response", []) if not blocks: - log.warning( - "expand.no_blocks", chunk=chunk_num, attempt=attempt - ) + log.warning("expand.no_blocks", chunk=chunk_num, attempt=attempt) continue # Validate: check for leaked block tags in content if not has_leaked_tags(blocks): break - log.warning( - "expand.leaked_tags", chunk=chunk_num, attempt=attempt - ) + log.warning("expand.leaked_tags", chunk=chunk_num, attempt=attempt) blocks = [] if not blocks: diff --git a/tests/prompts/baselines/test_director_baselines.py b/tests/prompts/baselines/test_director_baselines.py index 7a07e849..5b99deb2 100644 --- a/tests/prompts/baselines/test_director_baselines.py +++ b/tests/prompts/baselines/test_director_baselines.py @@ -30,7 +30,7 @@ from ..test_director_templates import ( # noqa: F401 active_context, MockCharacter, ) -from .conftest import capture_prompt, capture_all_prompts +from .conftest import capture_prompt AGENT = "director" @@ -274,17 +274,26 @@ def _make_test_beats() -> list[Beat]: return [ Beat( description="The protagonist discovers the door is locked from the inside.", - order=1, tension=0.3, pacing="slow", type="narration", + order=1, + tension=0.3, + pacing="slow", + type="narration", characters=["Elena"], ), Beat( description="Elena confronts Hero about what happened last night, demanding answers.", - order=2, tension=0.5, pacing="moderate", type="dialogue", + order=2, + tension=0.5, + pacing="moderate", + type="dialogue", characters=["Elena"], ), Beat( description="A sudden noise from the basement forces both characters to investigate together.", - order=3, tension=0.7, pacing="fast", type="action", + order=3, + tension=0.7, + pacing="fast", + type="action", characters=["Hero", "Elena"], ), ] @@ -301,6 +310,7 @@ class TestPlanExpandBaselines: director = active_context from talemate.instance import AGENTS + narrator = AGENTS.get("narrator") narrator.agent_type = "narrator" narrator.client = director.client @@ -352,6 +362,7 @@ class TestPlanExpandBaselines: director = active_context from talemate.instance import AGENTS + narrator = AGENTS.get("narrator") narrator.agent_type = "narrator" narrator.client = director.client @@ -408,9 +419,19 @@ class TestPlanExpandBaselines: narrator.content_use_writing_style = False blocks = [ - {"type": "narrator", "content": "The room was dark and cold. A chill ran down her spine."}, - {"type": "character", "name": "Elena", "content": "She stepped forward, her hands trembling. \"Who's there?\" she whispered."}, - {"type": "narrator", "content": "A chill ran through the room. The darkness pressed in from all sides."}, + { + "type": "narrator", + "content": "The room was dark and cold. A chill ran down her spine.", + }, + { + "type": "character", + "name": "Elena", + "content": 'She stepped forward, her hands trembling. "Who\'s there?" she whispered.', + }, + { + "type": "narrator", + "content": "A chill ran through the room. The darkness pressed in from all sides.", + }, ] director.client.send_prompt = AsyncMock( diff --git a/tests/test_plan_expand.py b/tests/test_plan_expand.py index 1ef165d6..d922dc47 100644 --- a/tests/test_plan_expand.py +++ b/tests/test_plan_expand.py @@ -9,8 +9,7 @@ Tests cover: - Chat creation for generate_arc modes """ -import pytest -from unittest.mock import Mock, AsyncMock, patch +from unittest.mock import Mock from talemate.agents.director.plan.expand import ( compute_chunks, @@ -25,7 +24,7 @@ def _make_beats(tensions: list[float]) -> list[Beat]: """Helper to create Beat objects with given tension values.""" return [ Beat( - description=f"Beat {i+1}", + description=f"Beat {i + 1}", order=i + 1, tension=t, pacing="moderate",