mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-11 20:34:02 +01:00
fix(lint): remove style preference rules from global ignores
Fixed violations: - PERF401: Use list comprehension (downloadCats, split) - SIM102: Combine nested if statements (keyboardCoop) - SIM113: Use enumerate (lichess_bot/tests) - B904: Add 'from None/e' to raises (engine, stockfish_analysis, generate_blunder_tests) - TRY300: Move return to else block (screen_locker) Per-file ignores added for TRY301: - lichess_bot/main.py: Null checks on subprocess streams - randomize_numbers/random_digits.py: Input validation Removed from global ignore (no violations): - RUF005, SIM103, SIM105, SIM108 Global ignore now only contains unavoidable conflicts: - D203/D213: Docstring style conflicts - COM812/ISC001: Formatter conflicts (per ruff docs)
This commit is contained in:
parent
83022f9b2c
commit
87cbcd5ff6
@ -23,9 +23,7 @@ while requests_send < MAX_REQUESTS:
|
|||||||
)
|
)
|
||||||
requests_send += 1
|
requests_send += 1
|
||||||
response = json.loads(res.text)
|
response = json.loads(res.text)
|
||||||
urls = []
|
urls = [cat.get("url") for cat in response]
|
||||||
for cat in response:
|
|
||||||
urls.append(cat.get("url"))
|
|
||||||
|
|
||||||
Path("./CATS2").mkdir(parents=True, exist_ok=True)
|
Path("./CATS2").mkdir(parents=True, exist_ok=True)
|
||||||
for url in urls:
|
for url in urls:
|
||||||
|
|||||||
@ -242,9 +242,10 @@ class KeyboardCoopGame:
|
|||||||
new_col = col_idx + dc
|
new_col = col_idx + dc
|
||||||
|
|
||||||
# Check bounds
|
# Check bounds
|
||||||
if 0 <= new_row < len(self.keyboard_layout):
|
if 0 <= new_row < len(self.keyboard_layout) and 0 <= new_col < len(
|
||||||
if 0 <= new_col < len(self.keyboard_layout[new_row]):
|
self.keyboard_layout[new_row]
|
||||||
adjacents.append(self.keyboard_layout[new_row][new_col])
|
):
|
||||||
|
adjacents.append(self.keyboard_layout[new_row][new_col])
|
||||||
|
|
||||||
self.key_adjacency[letter] = adjacents
|
self.key_adjacency[letter] = adjacents
|
||||||
|
|
||||||
|
|||||||
@ -99,7 +99,7 @@ class RandomEngine:
|
|||||||
move = chess.Move.from_uci(chosen_uci)
|
move = chess.Move.from_uci(chosen_uci)
|
||||||
except Exception:
|
except Exception:
|
||||||
msg = f"Engine returned invalid move: '{chosen_uci}' (output: {output!r})"
|
msg = f"Engine returned invalid move: '{chosen_uci}' (output: {output!r})"
|
||||||
raise RuntimeError(msg)
|
raise RuntimeError(msg) from None
|
||||||
|
|
||||||
if move not in board.legal_moves:
|
if move not in board.legal_moves:
|
||||||
msg = f"Engine returned illegal move for position: {chosen_uci}"
|
msg = f"Engine returned illegal move for position: {chosen_uci}"
|
||||||
|
|||||||
@ -41,9 +41,7 @@ def test_puzzle_engine_follow_solution(fen: str, moves_str: str) -> None:
|
|||||||
# Moves are space-separated UCIs alternating sides
|
# Moves are space-separated UCIs alternating sides
|
||||||
# starting from side-to-move in the FEN
|
# starting from side-to-move in the FEN
|
||||||
solution_moves = moves_str.split()
|
solution_moves = moves_str.split()
|
||||||
step = 0
|
for step, uci in enumerate(solution_moves, start=1):
|
||||||
for uci in solution_moves:
|
|
||||||
step += 1
|
|
||||||
# Engine move on this ply
|
# Engine move on this ply
|
||||||
mv, expl = eng.choose_move_with_explanation(board, time_budget_sec=0.5)
|
mv, expl = eng.choose_move_with_explanation(board, time_budget_sec=0.5)
|
||||||
assert mv is not None, f"No move returned at step {step}.\nExplanation: {expl}"
|
assert mv is not None, f"No move returned at step {step}.\nExplanation: {expl}"
|
||||||
|
|||||||
@ -178,7 +178,7 @@ def fen_and_uci_for_blunders(
|
|||||||
f"side {bl.side} in position FEN: {fen_before}. "
|
f"side {bl.side} in position FEN: {fen_before}. "
|
||||||
f"Error: {e}"
|
f"Error: {e}"
|
||||||
)
|
)
|
||||||
raise ValueError(msg)
|
raise ValueError(msg) from e
|
||||||
results.append((fen_before, move.uci(), best_uci, bl))
|
results.append((fen_before, move.uci(), best_uci, bl))
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
|||||||
@ -634,11 +634,11 @@ class ScreenLocker:
|
|||||||
try:
|
try:
|
||||||
with open(self.log_file) as f:
|
with open(self.log_file) as f:
|
||||||
logs = json.load(f)
|
logs = json.load(f)
|
||||||
|
|
||||||
today = datetime.now(tz=timezone.utc).strftime("%Y-%m-%d")
|
|
||||||
return today in logs
|
|
||||||
except (OSError, json.JSONDecodeError):
|
except (OSError, json.JSONDecodeError):
|
||||||
return False
|
return False
|
||||||
|
else:
|
||||||
|
today = datetime.now(tz=timezone.utc).strftime("%Y-%m-%d")
|
||||||
|
return today in logs
|
||||||
|
|
||||||
def save_workout_log(self) -> None:
|
def save_workout_log(self) -> None:
|
||||||
"""Save workout data to log file."""
|
"""Save workout data to log file."""
|
||||||
|
|||||||
@ -23,8 +23,7 @@ def calculate_symmetric_weights(
|
|||||||
next_weight = weights_left[-1] + factor
|
next_weight = weights_left[-1] + factor
|
||||||
weights_left.append(next_weight)
|
weights_left.append(next_weight)
|
||||||
else:
|
else:
|
||||||
for i in range(half_n - 1):
|
weights_left.extend(middle_weight - (i + 1) for i in range(half_n - 1))
|
||||||
weights_left.append(middle_weight - (i + 1))
|
|
||||||
|
|
||||||
if n % 2 == 0:
|
if n % 2 == 0:
|
||||||
weights = weights_left[::-1] + weights_left
|
weights = weights_left[::-1] + weights_left
|
||||||
|
|||||||
@ -159,7 +159,7 @@ def _parse_threads(value: str) -> int | None:
|
|||||||
return max(1, n)
|
return max(1, n)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
msg = "--threads must be an integer or 'auto'"
|
msg = "--threads must be an integer or 'auto'"
|
||||||
raise argparse.ArgumentTypeError(msg)
|
raise argparse.ArgumentTypeError(msg) from None
|
||||||
|
|
||||||
|
|
||||||
def _parse_hash_mb(value: str) -> int | None:
|
def _parse_hash_mb(value: str) -> int | None:
|
||||||
@ -171,7 +171,7 @@ def _parse_hash_mb(value: str) -> int | None:
|
|||||||
return max(16, mb)
|
return max(16, mb)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
msg = "--hash-mb must be an integer (MB) or 'auto'"
|
msg = "--hash-mb must be an integer (MB) or 'auto'"
|
||||||
raise argparse.ArgumentTypeError(msg)
|
raise argparse.ArgumentTypeError(msg) from None
|
||||||
|
|
||||||
|
|
||||||
def _detect_total_mem_mb() -> int | None:
|
def _detect_total_mem_mb() -> int | None:
|
||||||
|
|||||||
@ -31,19 +31,9 @@ ignore = [
|
|||||||
"D203", # 1 blank line required before class docstring (conflicts with D211)
|
"D203", # 1 blank line required before class docstring (conflicts with D211)
|
||||||
# D212 vs D213 conflict - we use D212 (summary on first line after """)
|
# D212 vs D213 conflict - we use D212 (summary on first line after """)
|
||||||
"D213", # Multi-line docstring summary should start at second line (conflicts with D212)
|
"D213", # Multi-line docstring summary should start at second line (conflicts with D212)
|
||||||
|
# Formatter conflicts - these rules conflict with ruff format
|
||||||
"COM812", # Trailing comma missing (conflicts with formatter)
|
"COM812", # Trailing comma missing (conflicts with formatter)
|
||||||
"ISC001", # Implicit string concatenation (conflicts with formatter)
|
"ISC001", # Implicit string concatenation (conflicts with formatter)
|
||||||
# Style preferences - relaxed for script-heavy repository
|
|
||||||
"PERF401", # manual-list-comprehension - style preference
|
|
||||||
"RUF005", # collection-literal-concatenation - style preference
|
|
||||||
"SIM102", # collapsible-if - style preference
|
|
||||||
"SIM103", # needless-bool - style preference
|
|
||||||
"SIM105", # suppressible-exception - style preference
|
|
||||||
"SIM108", # if-else-block - style preference
|
|
||||||
"SIM113", # enumerate-for-loop - style preference
|
|
||||||
"B904", # raise-without-from - style preference
|
|
||||||
"TRY300", # try-consider-else - style preference
|
|
||||||
"TRY301", # raise-within-try - style preference
|
|
||||||
]
|
]
|
||||||
|
|
||||||
# Allow ALL rules to be auto-fixed
|
# Allow ALL rules to be auto-fixed
|
||||||
@ -120,6 +110,7 @@ unfixable = []
|
|||||||
"PTH", # os.path patterns in existing code
|
"PTH", # os.path patterns in existing code
|
||||||
"LOG015", # Root logger in bot
|
"LOG015", # Root logger in bot
|
||||||
"G004", # f-strings in logging
|
"G004", # f-strings in logging
|
||||||
|
"TRY301", # Raise in try block for null checks on subprocess streams
|
||||||
]
|
]
|
||||||
"PYTHON/lichess_bot/engine.py" = [
|
"PYTHON/lichess_bot/engine.py" = [
|
||||||
"BLE001", # Blind except for engine error handling
|
"BLE001", # Blind except for engine error handling
|
||||||
@ -159,6 +150,7 @@ unfixable = []
|
|||||||
"S311", # Random for number randomization, not crypto
|
"S311", # Random for number randomization, not crypto
|
||||||
"LOG015", # Root logger in script
|
"LOG015", # Root logger in script
|
||||||
"G004", # f-strings in logging
|
"G004", # f-strings in logging
|
||||||
|
"TRY301", # Raise in try block for input validation
|
||||||
]
|
]
|
||||||
"PYTHON/keyboardCoop/main.py" = [
|
"PYTHON/keyboardCoop/main.py" = [
|
||||||
"FBT003", # Boolean positional values in pygame API calls (e.g., font.render)
|
"FBT003", # Boolean positional values in pygame API calls (e.g., font.render)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user