Fix all ruff linting errors

- Fix import ordering (isort)
- Remove unused imports
- Fix line too long (>100 chars)
- Fix variable naming (PIECES -> piece_chars)
- Fix bare except clause
- Remove unused variable
This commit is contained in:
Greg Hendrickson
2026-01-27 20:54:19 +00:00
parent ff643e1265
commit 8a5e1785dc
13 changed files with 111 additions and 94 deletions

View File

@@ -1,20 +1,22 @@
"""Tests for UI rendering - catches Rich markup errors before deployment."""
import pytest
from io import StringIO
from rich.align import Align
from rich.box import ROUNDED
from rich.console import Console
from rich.panel import Panel
from rich.table import Table
from rich.text import Text
from rich.align import Align
from rich.box import ROUNDED
def test_menu_render_no_markup_errors():
"""Test that the main menu renders without Rich markup errors."""
# Simulate the menu rendering code
output = StringIO()
console = Console(file=output, width=80, height=24, force_terminal=True, color_system="truecolor")
console = Console(
file=output, width=80, height=24, force_terminal=True, color_system="truecolor"
)
username = "testuser"
width = 80
@@ -35,10 +37,18 @@ def test_menu_render_no_markup_errors():
menu_table.add_column(justify="center")
menu_table.add_row(Text(f"Welcome, {username}!", style="cyan"))
menu_table.add_row("")
menu_table.add_row("[bright_white on blue] 1 [/bright_white on blue] Play vs AI [dim]♔ vs ♚[/dim]")
menu_table.add_row("[bright_white on magenta] 2 [/bright_white on magenta] Play vs Human [dim]♔ vs [/dim]")
menu_table.add_row("[bright_white on green] 3 [/bright_white on green] Learn & Practice [dim]📖[/dim]")
menu_table.add_row("[bright_white on red] q [/bright_white on red] Quit [dim]👋[/dim]")
menu_table.add_row(
"[bright_white on blue] 1 [/] Play vs AI [dim]♔ vs [/dim]"
)
menu_table.add_row(
"[bright_white on magenta] 2 [/] Play vs Human [dim]♔ vs ♔[/dim]"
)
menu_table.add_row(
"[bright_white on green] 3 [/] Learn & Practice [dim]📖[/dim]"
)
menu_table.add_row(
"[bright_white on red] q [/] Quit [dim]👋[/dim]"
)
menu_table.add_row("")
menu_table.add_row(Text("Press a key to select...", style="dim italic"))
@@ -93,7 +103,7 @@ def test_chess_board_render():
"""Test that chess board renders without errors."""
output = StringIO()
PIECES = {
piece_map = {
'K': '', 'Q': '', 'R': '', 'B': '', 'N': '', 'P': '',
'k': '', 'q': '', 'r': '', 'b': '', 'n': '', 'p': '',
}
@@ -106,8 +116,8 @@ def test_chess_board_render():
# Render rank 8 with pieces
pieces_row = ['r', 'n', 'b', 'q', 'k', 'b', 'n', 'r']
row = " 8 |"
for file, piece_char in enumerate(pieces_row):
char = PIECES.get(piece_char, '?')
for piece_char in pieces_row:
char = piece_map.get(piece_char, '?')
row += f" {char} |"
row += " 8"
lines.append(row)