Commit Graph

12 Commits

Author SHA1 Message Date
92e15e8909 Improve lichess_bot utils.py test coverage to 100%
- Add tests for _version_file_path environment override
- Add tests for missing and invalid version files
- Add tests for write failure error handling
2025-12-01 20:02:05 +01:00
d24b005809 fix: remove all pylint disable comments and enable all meta checks 2025-12-01 16:22:03 +01:00
0e73b27d50 fix: address all pylint warnings
- R0914 (too many locals): Extract helper functions in generate_jpeg.py,
  engine.py, lichess_api.py, main.py
- R0902 (too many instance attributes): Use dataclasses in keyboard_coop
- W0621 (redefined outer name): Rename parameters/variables to avoid shadowing
- W0201 (attribute outside init): Initialize all attrs in __init__
- R1705 (no-else-return): Remove unnecessary else after return
- C1805 (implicit booleaness): Use implicit boolean checks
- R1732 (consider-using-with): Use context manager for subprocess.Popen
- E0401 (import-error): Add pylint disable for optional deps (selenium, mitmproxy)
- Clean up pyproject.toml: update comments, remove redundant settings

Pylint score: 10.00/10
2025-12-01 16:11:15 +01:00
8ecc13cb56 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
6f1dfb769f fix(lint): restore S603 noqa for trusted subprocess call 2025-11-30 23:49:57 +01:00
1979089fcf fix(lint): fix S603 in engine.py and D100 in conftest.py
- 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
2025-11-30 23:43:34 +01:00
8aeee0d55a refactor(lichess_bot): reduce complexity with dataclasses and extracted functions
- Add GameState, GameMeta, BotContext dataclasses for state bundling
- Extract 20+ helper functions from nested closures to module level
- Fix C901, PLR0912, PLR0915 complexity violations
- Fix mypy type errors with proper type annotations
- Add noqa for intentional S603 (subprocess call to trusted internal script)
2025-11-30 23:40:53 +01:00
d22619b483 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
b1a5f245a2 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
dd2da6e2cc 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
b78f02cf05 fix: resolve PERF203 try-except in loop violations
- Extract try-except bodies into helper functions:
  - download_cats: _download_single_image()
  - randomize_numbers: _parse_single_number()
  - lichess_bot/main: _apply_move_to_board(), _process_event_stream(), _run_event_loop_iteration()
- Use else block for return statements after try (TRY300)
- Remove PERF203 from per-file ignores in pyproject.toml
2025-11-30 21:29:03 +01:00
2dd4e68edb 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