From fc8508fbd593b683314c58606687d41533c5e6b8 Mon Sep 17 00:00:00 2001 From: Cal Corum Date: Mon, 23 Mar 2026 08:50:11 -0500 Subject: [PATCH] refactor: rename Evolution badges to Refractor tier names MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Badge labels: [R] Refractor, [GR] Gold Refractor, [SF] Superfractor, [SF★] fully evolved - Fix broken {e} log format strings (restore `as e` + add f-string prefix) - Restore ruff.toml from main (branch had stripped global config) - Update all test assertions for new badge names (11/11 pass) Co-Authored-By: Claude Opus 4.6 (1M context) --- helpers/main.py | 11 ++++---- ruff.toml | 40 +++++++++++++++++++++++++++--- tests/test_card_embed_evolution.py | 26 +++++++++---------- 3 files changed, 55 insertions(+), 22 deletions(-) diff --git a/helpers/main.py b/helpers/main.py index 829654c..535ac29 100644 --- a/helpers/main.py +++ b/helpers/main.py @@ -115,7 +115,8 @@ async def get_card_embeds(card, include_stats=False) -> list: evo_state = await db_get(f"evolution/cards/{card['id']}") if evo_state and evo_state.get("current_tier", 0) > 0: tier = evo_state["current_tier"] - tier_badge = f"[{'EVO' if tier >= 4 else f'T{tier}'}] " + TIER_BADGES = {1: "R", 2: "GR", 3: "SF"} + tier_badge = f"[{TIER_BADGES.get(tier, 'SF★')}] " except Exception: pass @@ -210,9 +211,9 @@ async def get_card_embeds(card, include_stats=False) -> list: ) if evo_mon is not None: embed.add_field(name="Evolves Into", value=f"{evo_mon['p_name']}") - except Exception: + except Exception as e: logging.error( - "could not pull evolution: {e}", exc_info=True, stack_info=True + f"could not pull evolution: {e}", exc_info=True, stack_info=True ) if "420420" not in card["player"]["strat_code"]: try: @@ -221,9 +222,9 @@ async def get_card_embeds(card, include_stats=False) -> list: ) if evo_mon is not None: embed.add_field(name="Evolves From", value=f"{evo_mon['p_name']}") - except Exception: + except Exception as e: logging.error( - "could not pull evolution: {e}", exc_info=True, stack_info=True + f"could not pull evolution: {e}", exc_info=True, stack_info=True ) if include_stats: diff --git a/ruff.toml b/ruff.toml index 1971b0c..1b5220c 100644 --- a/ruff.toml +++ b/ruff.toml @@ -1,5 +1,37 @@ +# Ruff configuration for paper-dynasty discord bot +# See https://docs.astral.sh/ruff/configuration/ + +[lint] +# Rules suppressed globally because they reflect intentional project patterns: +# F403/F405: star imports — __init__.py files use `from .module import *` for re-exports +# E712: SQLAlchemy/SQLModel ORM comparisons require == syntax (not `is`) +# F541: f-strings without placeholders — 1000+ legacy occurrences; cosmetic, deferred +ignore = ["F403", "F405", "F541", "E712"] + +# Per-file suppressions for pre-existing violations in legacy code. +# New files outside these paths get the full rule set. +# Remove entries here as files are cleaned up. [lint.per-file-ignores] -# helpers/main.py uses star imports as a legacy pattern (api_calls, constants, -# discord_ui, etc.). F403/F405 are suppressed here to allow the pre-commit hook -# to pass without requiring a full refactor of the star import chain. -"helpers/main.py" = ["F403", "F405", "E722", "E721"] +# Core cogs — F841/F401 widespread; E711/E713/F811 pre-existing +"cogs/**" = ["F841", "F401", "E711", "E713", "F811"] +# Game engine — F841/F401 widespread; E722/F811 pre-existing bare-excepts and redefinitions +"in_game/**" = ["F841", "F401", "E722", "F811"] +# Helpers — F841/F401 widespread; E721/E722 pre-existing type-comparison and bare-excepts +"helpers/**" = ["F841", "F401", "E721", "E722"] +# Game logic and commands +"command_logic/**" = ["F841", "F401"] +# Test suite — E711/F811/F821 pre-existing test assertion patterns +"tests/**" = ["F841", "F401", "E711", "F811", "F821"] +# Utilities +"utilities/**" = ["F841", "F401"] +# Migrations +"migrations/**" = ["F401"] +# Top-level legacy files +"db_calls_gameplay.py" = ["F841", "F401"] +"gauntlets.py" = ["F841", "F401"] +"dice.py" = ["F841", "E711"] +"manual_pack_distribution.py" = ["F841"] +"play_lock.py" = ["F821"] +"paperdynasty.py" = ["F401"] +"api_calls.py" = ["F401"] +"health_server.py" = ["F401"] diff --git a/tests/test_card_embed_evolution.py b/tests/test_card_embed_evolution.py index e0bcd28..413ba28 100644 --- a/tests/test_card_embed_evolution.py +++ b/tests/test_card_embed_evolution.py @@ -103,7 +103,7 @@ class TestTierBadgeFormat: @pytest.mark.asyncio async def test_tier_one_badge(self): - """current_tier=1 should prefix title with [T1].""" + """current_tier=1 should prefix title with [R] (Refractor).""" card = _make_card() evo_state = {"current_tier": 1, "card_id": 1} @@ -111,11 +111,11 @@ class TestTierBadgeFormat: mock_db.side_effect = _patch_db_get(evo_response=evo_state) embeds = await _call_get_card_embeds(card) - assert embeds[0].title == "[T1] Mike Trout" + assert embeds[0].title == "[R] Mike Trout" @pytest.mark.asyncio async def test_tier_two_badge(self): - """current_tier=2 should prefix title with [T2].""" + """current_tier=2 should prefix title with [GR] (Gold Refractor).""" card = _make_card() evo_state = {"current_tier": 2, "card_id": 1} @@ -123,11 +123,11 @@ class TestTierBadgeFormat: mock_db.side_effect = _patch_db_get(evo_response=evo_state) embeds = await _call_get_card_embeds(card) - assert embeds[0].title == "[T2] Mike Trout" + assert embeds[0].title == "[GR] Mike Trout" @pytest.mark.asyncio async def test_tier_three_badge(self): - """current_tier=3 should prefix title with [T3].""" + """current_tier=3 should prefix title with [SF] (Superfractor).""" card = _make_card() evo_state = {"current_tier": 3, "card_id": 1} @@ -135,11 +135,11 @@ class TestTierBadgeFormat: mock_db.side_effect = _patch_db_get(evo_response=evo_state) embeds = await _call_get_card_embeds(card) - assert embeds[0].title == "[T3] Mike Trout" + assert embeds[0].title == "[SF] Mike Trout" @pytest.mark.asyncio - async def test_tier_four_evo_badge(self): - """current_tier=4 (fully evolved) should prefix title with [EVO].""" + async def test_tier_four_superfractor_badge(self): + """current_tier=4 (fully evolved) should prefix title with [SF★].""" card = _make_card() evo_state = {"current_tier": 4, "card_id": 1} @@ -147,7 +147,7 @@ class TestTierBadgeFormat: mock_db.side_effect = _patch_db_get(evo_response=evo_state) embeds = await _call_get_card_embeds(card) - assert embeds[0].title == "[EVO] Mike Trout" + assert embeds[0].title == "[SF★] Mike Trout" class TestTierBadgeInTitle: @@ -163,16 +163,16 @@ class TestTierBadgeInTitle: mock_db.side_effect = _patch_db_get(evo_response=evo_state) embeds = await _call_get_card_embeds(card) - assert embeds[0].title.startswith("[T2] ") + assert embeds[0].title.startswith("[GR] ") assert "Juan Soto" in embeds[0].title class TestFullyEvolvedBadge: - """Unit: fully evolved card shows [EVO] badge.""" + """Unit: fully evolved card shows [SF★] badge.""" @pytest.mark.asyncio async def test_fully_evolved_badge(self): - """T4 card should show [EVO] prefix, not [T4].""" + """T4 card should show [SF★] prefix, not [T4].""" card = _make_card() evo_state = {"current_tier": 4} @@ -180,7 +180,7 @@ class TestFullyEvolvedBadge: mock_db.side_effect = _patch_db_get(evo_response=evo_state) embeds = await _call_get_card_embeds(card) - assert embeds[0].title.startswith("[EVO] ") + assert embeds[0].title.startswith("[SF★] ") assert "[T4]" not in embeds[0].title