diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 18b3cf1..01aadd1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -54,6 +54,22 @@ repos: args: [--fix=lf] - id: requirements-txt-fixer + # =========================================================================== + # NOQA BLOCKER - Zero tolerance for noqa/type:ignore suppression comments + # =========================================================================== + - repo: local + hooks: + - id: no-noqa + name: Block noqa comments + entry: '(?i)#\s*(noqa|type:\s*ignore)' + language: pygrep + types: [python] + - id: no-ruff-noqa + name: Block ruff noqa file-level comments + entry: '(?i)#\s*ruff:\s*noqa' + language: pygrep + types: [python] + # =========================================================================== # RUFF - Fast Python linter and formatter (replaces black, isort, flake8, etc.) # =========================================================================== diff --git a/python_pkg/lichess_bot/tools/generate_blunder_tests.py b/python_pkg/lichess_bot/tools/generate_blunder_tests.py index 9612757..0181a26 100755 --- a/python_pkg/lichess_bot/tools/generate_blunder_tests.py +++ b/python_pkg/lichess_bot/tools/generate_blunder_tests.py @@ -121,7 +121,7 @@ def extract_pgn(text: str) -> str | None: return None start = m.end() pgn = text[start:].strip() - return pgn if pgn else None + return pgn or None def san_list_from_game(game: chess.pgn.Game) -> list[str]: diff --git a/python_pkg/music_gen/music_generator.py b/python_pkg/music_gen/music_generator.py index 34ad8ec..a2e5e45 100755 --- a/python_pkg/music_gen/music_generator.py +++ b/python_pkg/music_gen/music_generator.py @@ -17,6 +17,7 @@ import argparse from datetime import datetime, timezone from pathlib import Path import sys +from typing import Any import warnings # Suppress warnings for cleaner output @@ -161,7 +162,7 @@ def select_model_size(user_choice: str | None = None) -> str: def load_model( model_size: str = "medium", -) -> tuple: # type: ignore[type-arg] +) -> tuple[Any, Any]: """Load the MusicGen model. Args: @@ -327,7 +328,7 @@ def _split_into_sentences(text: str) -> list[str]: if current: result.append(current) - return result if result else [text] + return result or [text] def _resample_audio( diff --git a/python_pkg/randomize_numbers/random_digits.py b/python_pkg/randomize_numbers/random_digits.py index e7bcaae..26c23c2 100644 --- a/python_pkg/randomize_numbers/random_digits.py +++ b/python_pkg/randomize_numbers/random_digits.py @@ -61,7 +61,7 @@ def _parse_single_number(num_str: str) -> tuple[float, int] | None: """ try: float_num = float(num_str) - digits_count = len(num_str.split(".")[-1]) if "." in num_str else 0 + digits_count = len(num_str.rsplit(".", maxsplit=1)[-1]) if "." in num_str else 0 except ValueError: return None return float_num, digits_count