Ruff automatic fixes and formatting.

This commit is contained in:
2026-05-25 01:57:17 +00:00
parent 5f69b5365f
commit 0e5251ab91
24 changed files with 417 additions and 448 deletions
+9 -12
View File
@@ -1,12 +1,9 @@
#!/usr/bin/env python3
"""
RTorrent Client - Communicate with rtorrent via XMLRPC over SCGI socket.
"""
"""RTorrent Client - Communicate with rtorrent via XMLRPC over SCGI socket."""
import socket
import xmlrpc.client
from pathlib import Path
from typing import Dict, List, Optional
class SCGITransport(xmlrpc.client.Transport):
@@ -68,8 +65,7 @@ class RTorrentClient:
return set()
def load_torrent(self, torrent_path: Path, download_dir: Path) -> bool:
"""
Load a torrent file and set its download directory.
"""Load a torrent file and set its download directory.
Uses load.start_verbose to load and immediately start/hash-check.
Args:
@@ -78,6 +74,7 @@ class RTorrentClient:
Returns:
True if successful, False otherwise
"""
try:
# load.start_verbose with d.directory.set to specify download location
@@ -90,7 +87,7 @@ class RTorrentClient:
print(f"Error loading torrent {torrent_path}: {e}")
return False
def get_torrent_info(self, info_hash: str) -> Optional[Dict]:
def get_torrent_info(self, info_hash: str) -> dict | None:
"""Get info about a loaded torrent."""
try:
name = self.proxy.d.name(info_hash)
@@ -112,12 +109,12 @@ class RTorrentClient:
print(f"Error getting torrent info for {info_hash}: {e}")
return None
def get_unregistered_torrents(self) -> List[Dict]:
"""
Find all torrents with 'unregistered' or 'not registered' tracker errors.
def get_unregistered_torrents(self) -> list[dict]:
"""Find all torrents with 'unregistered' or 'not registered' tracker errors.
Returns:
List of torrent info dicts for torrents with registration errors
"""
unregistered = []
try:
@@ -139,8 +136,7 @@ class RTorrentClient:
return unregistered
def remove_torrent(self, info_hash: str, delete_files: bool = False) -> bool:
"""
Remove a torrent from rtorrent.
"""Remove a torrent from rtorrent.
Args:
info_hash: The info hash of the torrent to remove
@@ -148,6 +144,7 @@ class RTorrentClient:
Returns:
True if successful, False otherwise
"""
try:
if delete_files: