BLE001 except Exception replaced for more specific types.

This commit is contained in:
2026-05-25 02:19:41 +00:00
parent 54a4b57230
commit 3768967e7d
12 changed files with 50 additions and 39 deletions
+1 -1
View File
@@ -256,7 +256,7 @@ def main() -> None:
print(f"✓ Built successfully: {zip_path}")
print(f" Size: {zip_path.stat().st_size / (1024 * 1024):.1f} MB")
except Exception as e:
except (FileNotFoundError, OSError, RuntimeError, ValueError) as e:
print(f"✗ Build failed: {e}", file=sys.stderr)
sys.exit(1)
+1 -1
View File
@@ -222,7 +222,7 @@ def main() -> None:
print("\nDone. To publish to PyPI, run:")
print(" uv publish")
except Exception as e:
except (FileNotFoundError, OSError, RuntimeError, ValueError, httpx.HTTPError) as e:
print(f"✗ Release failed: {e}", file=sys.stderr)
sys.exit(1)
+4 -4
View File
@@ -88,7 +88,7 @@ def parse_torrent(filepath: Path) -> TorrentInfo | None:
try:
with Path(filepath).open("rb") as f:
data = bencodepy.decode(f.read())
except Exception as e:
except (OSError, ValueError, TypeError) as e:
print(f"Error parsing {filepath}: {e}")
return None
@@ -381,7 +381,7 @@ Examples:
try:
torrent_file.unlink()
removed_torrent_files += 1
except Exception:
except OSError:
pass
# Delete the downloaded files
@@ -393,7 +393,7 @@ Examples:
download_path.unlink()
removed_downloads += 1
print(f" [DEL] {download_path}")
except Exception as e:
except OSError as e:
print(f" [ERR] {download_path}: {e}")
else:
print(f" [DEL] {torrent_info['name']} (no data)")
@@ -442,7 +442,7 @@ Examples:
try:
torrent.path.unlink()
print(f"Removed: {torrent.path}")
except Exception as e:
except OSError as e:
print(f"Failed to remove {torrent.path}: {e}")