mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-24 05:46:20 +01:00
Enable TRY401: remove redundant exception object from logging.exception
This commit is contained in:
parent
b5bb4ec9aa
commit
6a519db40f
@ -40,5 +40,5 @@ while requests_send < MAX_REQUESTS:
|
|||||||
|
|
||||||
logging.info(f"Saved {url} as {image_path}")
|
logging.info(f"Saved {url} as {image_path}")
|
||||||
|
|
||||||
except requests.exceptions.RequestException as e:
|
except requests.exceptions.RequestException:
|
||||||
logging.exception(f"Failed to download {url}: {e}")
|
logging.exception(f"Failed to download {url}")
|
||||||
|
|||||||
@ -41,8 +41,8 @@ class LichessAPI:
|
|||||||
logging.info(f"HTTP {method} {url} -> sending")
|
logging.info(f"HTTP {method} {url} -> sending")
|
||||||
try:
|
try:
|
||||||
r = self.session.request(method, url, **kwargs)
|
r = self.session.request(method, url, **kwargs)
|
||||||
except Exception as e:
|
except Exception:
|
||||||
logging.exception(f"HTTP {method} {url} -> exception: {e}")
|
logging.exception(f"HTTP {method} {url} -> exception")
|
||||||
raise
|
raise
|
||||||
elapsed = time.monotonic() - t0
|
elapsed = time.monotonic() - t0
|
||||||
status = r.status_code
|
status = r.status_code
|
||||||
|
|||||||
@ -235,8 +235,8 @@ def run_bot(log_level: str = "INFO", decline_correspondence: bool = False) -> No
|
|||||||
break
|
break
|
||||||
elif et in {"chatLine", "opponentGone"}:
|
elif et in {"chatLine", "opponentGone"}:
|
||||||
continue
|
continue
|
||||||
except Exception as e:
|
except Exception:
|
||||||
logging.exception(f"Game {game_id} thread error: {e}")
|
logging.exception(f"Game {game_id} thread error")
|
||||||
finally:
|
finally:
|
||||||
# On game end, write full PGN to the log file
|
# On game end, write full PGN to the log file
|
||||||
try:
|
try:
|
||||||
|
|||||||
@ -335,8 +335,8 @@ def _process_single_log(log_path: str) -> int:
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
blunders = parse_columns_for_blunders(text)
|
blunders = parse_columns_for_blunders(text)
|
||||||
except Exception as e:
|
except Exception:
|
||||||
logging.exception(f"Error parsing Columns in {os.path.basename(log_path)}: {e}")
|
logging.exception(f"Error parsing Columns in {os.path.basename(log_path)}")
|
||||||
return 2
|
return 2
|
||||||
if not blunders:
|
if not blunders:
|
||||||
logging.warning(
|
logging.warning(
|
||||||
@ -351,9 +351,9 @@ def _process_single_log(log_path: str) -> int:
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
cases = fen_and_uci_for_blunders(pgn_text, blunders)
|
cases = fen_and_uci_for_blunders(pgn_text, blunders)
|
||||||
except Exception as e:
|
except Exception:
|
||||||
logging.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
|
return 2
|
||||||
if not cases:
|
if not cases:
|
||||||
|
|||||||
@ -85,7 +85,7 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
logging.info(f"Original numbers: {numbers}")
|
logging.info(f"Original numbers: {numbers}")
|
||||||
logging.info(f"Randomized numbers: {formatted_numbers}")
|
logging.info(f"Randomized numbers: {formatted_numbers}")
|
||||||
except ValueError as e:
|
except ValueError:
|
||||||
logging.exception(f"Error: {e}")
|
logging.exception("Error processing numbers")
|
||||||
logging.exception("Please provide valid numbers and percentages.")
|
logging.exception("Please provide valid numbers and percentages.")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|||||||
@ -58,7 +58,6 @@ ignore = [
|
|||||||
"FBT003", # Boolean positional value - common pattern
|
"FBT003", # Boolean positional value - common pattern
|
||||||
"ARG001", # Unused function argument - often needed for API compatibility
|
"ARG001", # Unused function argument - often needed for API compatibility
|
||||||
"ARG002", # Unused method 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
|
"PERF203", # try-except-in-loop - often necessary
|
||||||
"PGH003", # blanket-type-ignore - existing code
|
"PGH003", # blanket-type-ignore - existing code
|
||||||
"PLC0415", # import-outside-top-level - sometimes necessary
|
"PLC0415", # import-outside-top-level - sometimes necessary
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user