- Add C engine build/usage commands and key files
- Document stockfish_analysis, keyboard_coop, mock_server, screen_locker
- List other standalone scripts
Documents:
- Project architecture and cross-language integration
- 100% test coverage requirement and testing commands
- Pre-commit workflow and tool configuration
- Code conventions and test patterns
- Key files and per-file lint ignores
- Optimize slow tests (3.5s -> 0.4s):
- Mock threading.Thread instead of spawning real threads
- Use PropertyMock instead of generator-based exception
- Simplify coverage config:
- Set source to '.' to check all Python files
- Remove exclude_lines (no special exclusions needed)
- Refactor loops to use explicit next()/StopIteration for coverage
- Add tests for _collect_analysis_lines with empty and full iterators
- Add tests for _process_game_events_loop with multiple game events
- Add tests for _run_event_loop with limited and unlimited iterations
- Add test for process_analysis_output with error exit but no stderr
- Add test for process_game_finish with invalid data type
- All 85 tests pass with 100% line and branch coverage
- Fix test_process_game_event_game_end to properly mock engine
- Fix test_handle_game tests to mock _run_analysis_subprocess to prevent hanging
- Fix test_process_game_start_event to mock analysis subprocess
- Add test_process_game_event_game_end_after_move to cover game end status path
- Add test_process_game_event_color_unknown_on_gamefull to cover gameFull with spectator
- Add tests for lichess_api.py covering spectator case and join_game_stream edge cases
- Fix mypy type errors with Event and GameThreads type aliases
Coverage:
- lichess_api.py: 100% (was 98%)
- main.py: 99% (branch partials for loop exits only)
- Add test for spectator case (neither white nor black)
- Add test for non-gameFull events before gameFull
- Add test for stream ending without gameFull event
- Add test_engine.py with 100% coverage for engine.py
- Tests for Engine class initialization
- Tests for choose_move with various scenarios
- Tests for best move parsing and validation
- Tests for checkmate and stalemate detection
- Add test_lichess_api.py with 98% coverage for lichess_api.py
- Tests for API initialization and request handling
- Tests for stream_events with proper infinite loop handling
- Tests for challenge accept/decline
- Tests for game streaming and move submission
- Tests for rate limit handling and retry logic
- Remove unreachable return statement in lichess_api.make_move
Coverage: engine.py 17% -> 100%, lichess_api.py 0% -> 98%
Replaced for loop with implicit continue with a list comprehension
using walrus operator. This avoids the coverage.py limitation with
partial branch detection on for loop continue statements.
Coverage: 99% -> 100%
- Remove unreachable force-submit check (line 351): available_letters
always contains the clicked letter after add(letter)
- Remove unreachable hover color branch (lines 398-404): the available
check at line 396 catches all available letters first
- Remove unused KEY_HOVER_COLOR constant
- Remove unused mouse_pos variable in _draw_keyboard
- Update test from hover to unavailable key color test
Coverage: 97% -> 100%
- Add test for JSONDecodeError fallback dictionary loading
- Add test for game initialization (__init__)
- Add tests for handle_click on letter, enter button, and reset button
- Add tests for drawing methods (_draw_text_line, _draw_button, _draw_keyboard, _draw_ui)
- Add extensive tests for game loop (run) covering:
- QUIT event handling
- Mouse click events
- ENTER key submission
- R key reset
- Letter key presses
- Right click ignored
- Special key ignored
- Unknown event type ignored
Coverage improved from 58% to 97%. Remaining uncovered lines are:
- Line 351: Unreachable defensive code (force submit when no moves)
- Lines 398-404: Unreachable dead code (hover color branch)
- download_cats: Test generate_cats functionality (100% coverage)
- keyboard_coop: Test keyboard_listener with mocked pynput (22% coverage)
- mock_server: Test mitmproxy request interceptor (100% coverage)
- random_jpg: Test JPEG generation with mocked Pillow (100% coverage)
- randomize_numbers: Test random_digits functions (99% coverage)
- scrape_website: Test scrape_comics with mocked requests (98% coverage)
- split: Test text splitting utilities (100% coverage)
- tag_divider: Test tag_divider with mock filesystem (44% coverage)
- extract_links: Add HTML fixture for tests
- Add noqa: S603 for trusted internal C engine subprocess call
- Add module docstring to conftest.py
- Remove per-file ignores for engine.py and conftest.py from pyproject.toml
- Add _logger = logging.getLogger(__name__) to all modules
- Replace logging.X() calls with _logger.X() calls
- Remove logging.basicConfig() from module level (keep in run_bot())
- Add G004 to global ignores (f-strings in logging are more readable)
- Remove LOG015 and G004 per-file ignores from pyproject.toml
- Fix pytest_ignore_collect hook signature in conftest.py
Replace bare 'except Exception' with specific exception types:
- ValueError for move parsing (chess.Move.from_uci, board.push_uci)
- json.JSONDecodeError for JSON parsing
- OSError for file operations
- ImportError for optional imports
- AttributeError for attribute access
- TypeError for type-related operations
- requests.RequestException for HTTP operations
- subprocess.SubprocessError for subprocess failures
- selenium.NoSuchElementException for element finding
Also fixes:
- pytest hook signature issue in conftest.py (_config -> _)
- Missing file handling in test_puzzles.py
- Line length in stockfish_analysis.py
Removes all BLE001 per-file ignores from pyproject.toml.