fix: resolve remaining ruff violations (FURB110, PLC0207)

- generate_blunder_tests.py: use 'or' instead of ternary (FURB110)
- music_generator.py: use 'or' instead of ternary (FURB110), fix type: ignore
- random_digits.py: use rsplit with maxsplit instead of split (PLC0207)
This commit is contained in:
Krzysztof Rudnicki 2026-03-14 17:51:55 +01:00
parent a77fd7f0fd
commit e7d2ecabb1
4 changed files with 21 additions and 4 deletions

View File

@ -54,6 +54,22 @@ repos:
args: [--fix=lf] args: [--fix=lf]
- id: requirements-txt-fixer - 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.) # RUFF - Fast Python linter and formatter (replaces black, isort, flake8, etc.)
# =========================================================================== # ===========================================================================

View File

@ -121,7 +121,7 @@ def extract_pgn(text: str) -> str | None:
return None return None
start = m.end() start = m.end()
pgn = text[start:].strip() 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]: def san_list_from_game(game: chess.pgn.Game) -> list[str]:

View File

@ -17,6 +17,7 @@ import argparse
from datetime import datetime, timezone from datetime import datetime, timezone
from pathlib import Path from pathlib import Path
import sys import sys
from typing import Any
import warnings import warnings
# Suppress warnings for cleaner output # Suppress warnings for cleaner output
@ -161,7 +162,7 @@ def select_model_size(user_choice: str | None = None) -> str:
def load_model( def load_model(
model_size: str = "medium", model_size: str = "medium",
) -> tuple: # type: ignore[type-arg] ) -> tuple[Any, Any]:
"""Load the MusicGen model. """Load the MusicGen model.
Args: Args:
@ -327,7 +328,7 @@ def _split_into_sentences(text: str) -> list[str]:
if current: if current:
result.append(current) result.append(current)
return result if result else [text] return result or [text]
def _resample_audio( def _resample_audio(

View File

@ -61,7 +61,7 @@ def _parse_single_number(num_str: str) -> tuple[float, int] | None:
""" """
try: try:
float_num = float(num_str) 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: except ValueError:
return None return None
return float_num, digits_count return float_num, digits_count