Enable TRY401: remove redundant exception object from logging.exception

This commit is contained in:
Krzysztof kuhy Rudnicki 2025-11-30 15:03:50 +01:00
parent b5bb4ec9aa
commit 6a519db40f
6 changed files with 12 additions and 13 deletions

View File

@ -40,5 +40,5 @@ while requests_send < MAX_REQUESTS:
logging.info(f"Saved {url} as {image_path}")
except requests.exceptions.RequestException as e:
logging.exception(f"Failed to download {url}: {e}")
except requests.exceptions.RequestException:
logging.exception(f"Failed to download {url}")

View File

@ -41,8 +41,8 @@ class LichessAPI:
logging.info(f"HTTP {method} {url} -> sending")
try:
r = self.session.request(method, url, **kwargs)
except Exception as e:
logging.exception(f"HTTP {method} {url} -> exception: {e}")
except Exception:
logging.exception(f"HTTP {method} {url} -> exception")
raise
elapsed = time.monotonic() - t0
status = r.status_code

View File

@ -235,8 +235,8 @@ def run_bot(log_level: str = "INFO", decline_correspondence: bool = False) -> No
break
elif et in {"chatLine", "opponentGone"}:
continue
except Exception as e:
logging.exception(f"Game {game_id} thread error: {e}")
except Exception:
logging.exception(f"Game {game_id} thread error")
finally:
# On game end, write full PGN to the log file
try:

View File

@ -335,8 +335,8 @@ def _process_single_log(log_path: str) -> int:
try:
blunders = parse_columns_for_blunders(text)
except Exception as e:
logging.exception(f"Error parsing Columns in {os.path.basename(log_path)}: {e}")
except Exception:
logging.exception(f"Error parsing Columns in {os.path.basename(log_path)}")
return 2
if not blunders:
logging.warning(
@ -351,9 +351,9 @@ def _process_single_log(log_path: str) -> int:
try:
cases = fen_and_uci_for_blunders(pgn_text, blunders)
except Exception as e:
except Exception:
logging.exception(
f"Error converting SAN to UCI in {os.path.basename(log_path)}: {e}"
f"Error converting SAN to UCI in {os.path.basename(log_path)}"
)
return 2
if not cases:

View File

@ -85,7 +85,7 @@ if __name__ == "__main__":
logging.info(f"Original numbers: {numbers}")
logging.info(f"Randomized numbers: {formatted_numbers}")
except ValueError as e:
logging.exception(f"Error: {e}")
except ValueError:
logging.exception("Error processing numbers")
logging.exception("Please provide valid numbers and percentages.")
sys.exit(1)

View File

@ -58,7 +58,6 @@ ignore = [
"FBT003", # Boolean positional value - common pattern
"ARG001", # Unused function argument - often needed for API compatibility
"ARG002", # Unused method argument - often needed for API compatibility
"TRY401", # Verbose log message - acceptable
"PERF203", # try-except-in-loop - often necessary
"PGH003", # blanket-type-ignore - existing code
"PLC0415", # import-outside-top-level - sometimes necessary