Commit Graph

9 Commits

Author SHA1 Message Date
8f2fbd2311 refactor: enforce 500-line limit on all Python source files
Split 18+ Python files that exceeded 500 lines into smaller modules
with helper files (prefixed with _). All functions are re-exported
from the original modules to maintain backward compatibility with
test patches and external imports.

Files split:
- moviepy_showcase.py (1212 -> 302 + 3 helpers)
- anki_generator.py (1174 -> 473 + 4 helpers)
- test_analyze_chess_game.py (1152 -> 361 + 2 parts)
- poker_modifier_app.py (1024 -> 263 + 2 helpers)
- transcribe_fw.py (1007 -> 342 + 3 helpers)
- music_generator.py (1002 -> 319 + 2 helpers)
- translator.py (951 -> 442 + 2 helpers)
- cinema_planner.py (893 -> 369 + 2 helpers)
- lichess_bot/main.py (757 -> 495 + _game_logic.py)
- test_translator.py (725 -> 289 + part2 + conftest)
- test_lichess_api.py (680 -> 475 + part2)
- learning_pipe.py (668 -> 375 + 2 helpers)
- cache.py (655 -> 360 + _cache_decks.py)
- analyze_chess_game.py (632 -> 463 + _move_analysis.py)
- visualize_q02.py (609 -> 371 + helper)
- repo_explorer.py (602 -> 347 + 2 helpers)
- keyboard_coop/main.py (515 -> 416 + _dictionary.py)
- scanning.py (501 -> 314 + _enforce_loop.py)

All tests pass: 144 lichess_bot (100% branch coverage), 243 others.
No new lint errors introduced.
2026-03-17 22:47:42 +01:00
5a8be96f94 feat: added run sh and makefile scripts 2026-02-22 22:00:50 +01:00
3d89e3e1fd Add comprehensive tests for stockfish_analysis (100% coverage)
- Create test_analyze_chess_game.py with 90 tests covering all functions
- Add tests for PGN extraction, score conversion, move classification
- Add tests for engine configuration, memory detection, analysis
- Add pragma: no branch for unreachable code paths
- Update pyproject.toml with coverage exclusions
- All pre-commit hooks pass (ruff, mypy, pylint, bandit)
2025-12-02 22:58:06 +01:00
52476d1b15 fix(lint): fix G004 and PTH123 violations across codebase
- Convert f-string logging to % style (G004)
- Convert open() to Path.open() (PTH123)
- Remove G004 and PTH123 from global ignores in pyproject.toml
2025-11-30 23:57:49 +01:00
a0761eccfc refactor(stockfish_analysis): reduce complexity of main() function
Break down monolithic main() into smaller, focused functions:
- _build_argument_parser(): CLI argument setup
- _load_game(): PGN file loading and parsing
- _configure_threads/hash/multipv/nnue(): Engine configuration helpers
- _setup_engine(): Engine initialization orchestration
- _get_best_move(): Engine best move extraction
- _evaluate_position(): Position evaluation wrapper
- _classify_mate_move(): Mate score classification logic
- _analyze_single_move(): Single move analysis
- _log_move_analysis(): Move analysis logging
- _run_analysis(): Analysis loop orchestration
- _analyze_last_move/all_moves(): Specific analysis modes

Add dataclasses MoveAnalysis and AnalysisContext to bundle related
parameters, improving code organization and reducing function signatures.

This removes the need for C901, PLR0912, PLR0915 per-file ignores
as all functions now comply with complexity limits.
2025-11-30 23:23:10 +01:00
3f9ba376e0 fix(lint): convert os.path to pathlib - remove PTH per-file ignores
- Converted os.path patterns to pathlib.Path in 15+ files
- os.path.join → Path /
- os.path.dirname → Path.parent
- os.path.exists → Path.exists()
- os.path.isfile → Path.is_file()
- os.path.abspath → Path.resolve()
- os.mkdir → Path.mkdir()
- os.listdir → Path.iterdir()
- os.getcwd → Path.cwd()
- os.replace → Path.replace()
- Updated function type hints to accept str | Path

Added PTH123 (open() vs Path.open()) to global ignores as stylistic preference
2025-11-30 23:03:03 +01:00
2ffa1cc169 fix(lint): LOG015 - replace root logger with module loggers
- 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
2025-11-30 21:59:24 +01:00
e2d0c103ae fix(lint): BLE001 - replace blind except with specific exceptions
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.
2025-11-30 21:37:47 +01:00
22333931cc refactor: rename folders to fix N999, INP001, S311 linting rules
- Rename PYTHON/ to python_pkg/ (fix N999 uppercase folder)
- Rename camelCase folders to snake_case:
  - randomJPG -> random_jpg
  - tagDivider -> tag_divider
  - downloadCats -> download_cats
  - keyboardCoop -> keyboard_coop
  - extractLinks -> extract_links
  - scapeWebsite -> scrape_website
- Rename camelCase files:
  - generateJpeg.py -> generate_jpeg.py
  - tagDivider.py -> tag_divider.py
- Rename poker-modifier-app to poker_modifier_app (fix INP001)
- Add __init__.py to poker_modifier_app
- Replace random module with secrets.SystemRandom (fix S311)
- Fix S110 try-except-pass with contextlib.suppress
- Update all imports and config references
2025-11-30 21:20:17 +01:00