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,9 +1,9 @@
"""Tests for SSH server functionality."""
import asyncio
import pytest
from unittest.mock import AsyncMock, MagicMock, patch
import pytest
class TestShellMateSSHServer:
"""Test SSH server authentication."""
@@ -113,9 +113,10 @@ class TestChessBoard:
def test_board_initialization(self):
"""Board should initialize with standard position."""
from shellmate.tui.widgets.board import ChessBoardWidget
import chess
from shellmate.tui.widgets.board import ChessBoardWidget
widget = ChessBoardWidget()
assert widget.board.fen() == chess.STARTING_FEN
@@ -136,9 +137,10 @@ class TestChessBoard:
def test_square_selection(self):
"""Selecting a square should show legal moves."""
from shellmate.tui.widgets.board import ChessBoardWidget
import chess
from shellmate.tui.widgets.board import ChessBoardWidget
widget = ChessBoardWidget()
# Select e2 pawn
@@ -152,9 +154,10 @@ class TestChessBoard:
def test_square_deselection(self):
"""Deselecting should clear legal moves."""
from shellmate.tui.widgets.board import ChessBoardWidget
import chess
from shellmate.tui.widgets.board import ChessBoardWidget
widget = ChessBoardWidget()
widget.select_square(chess.E2)
widget.select_square(None)
@@ -251,9 +254,10 @@ class TestIntegration:
@pytest.mark.asyncio
async def test_server_starts(self):
"""Server should start without errors."""
from shellmate.ssh.server import start_server
import tempfile
import os
import tempfile
from shellmate.ssh.server import start_server
# Create a temporary host key
with tempfile.TemporaryDirectory() as tmpdir:

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)