Skip to content

Commit 187edbc

Browse files
committed
style: format code with ruff
1 parent dbba1db commit 187edbc

File tree

13 files changed

+22
-80
lines changed

13 files changed

+22
-80
lines changed

tmdbfusion/cli/commands.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,7 @@ def _ensure_deps() -> None:
4949
5050
"""
5151
if not _CLICK_AVAILABLE:
52-
msg = (
53-
"The 'click' library is required for CLI. "
54-
"Install with: pip install tmdbfusion[cli]"
55-
)
52+
msg = "The 'click' library is required for CLI. Install with: pip install tmdbfusion[cli]"
5653
raise ImportError(msg)
5754

5855

@@ -344,9 +341,7 @@ def bulk_movies(
344341
import msgspec
345342

346343
data = [msgspec.to_builtins(m) for m in items]
347-
Path(output).write_text(
348-
json.dumps(data, indent=2), encoding="utf-8"
349-
)
344+
Path(output).write_text(json.dumps(data, indent=2), encoding="utf-8")
350345
click.echo(f"Saved to {output}")
351346
elif output_format == "json":
352347
_print_json(items)

tmdbfusion/cli/console.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,7 @@ def _ensure_rich() -> None:
4141
4242
"""
4343
if not _RICH_AVAILABLE:
44-
msg = (
45-
"The 'rich' library is required for console output. "
46-
"Install it with: pip install tmdbfusion[rich]"
47-
)
44+
msg = "The 'rich' library is required for console output. Install it with: pip install tmdbfusion[rich]"
4845
raise ImportError(msg)
4946

5047

tmdbfusion/core/async_client.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,7 @@ def paginate(
210210
self,
211211
method: typing.Callable[..., typing.Awaitable[typing.Any]],
212212
*,
213-
map_response: typing.Callable[[typing.Any], list[typing.Any]]
214-
| None = None,
213+
map_response: typing.Callable[[typing.Any], list[typing.Any]] | None = None,
215214
**kwargs: typing.Any,
216215
) -> typing.AsyncIterator[typing.Any]:
217216
"""Paginate through API results.
@@ -319,11 +318,7 @@ async def _request(
319318
self._update_rate_limits(response)
320319

321320
# Cache successful GET responses
322-
if (
323-
self._cache
324-
and method == "GET"
325-
and 200 <= response.status_code < 300
326-
) and cache_key:
321+
if (self._cache and method == "GET" and 200 <= response.status_code < 300) and cache_key:
327322
self._cache.set(cache_key, response)
328323

329324
return response

tmdbfusion/core/http.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,7 @@ def request(
131131
timeout=timeout,
132132
)
133133
# Retry on 5xx errors or 429
134-
if (
135-
500 <= response.status_code < 600
136-
or response.status_code == 429
137-
) and attempt < self._retries:
134+
if (500 <= response.status_code < 600 or response.status_code == 429) and attempt < self._retries:
138135
sleep_time = self._backoff_factor * (2**attempt)
139136
if response.status_code == 429:
140137
# Respect Retry-After if present
@@ -215,10 +212,7 @@ async def request(
215212
timeout=timeout,
216213
)
217214
# Retry on 5xx errors or 429
218-
if (
219-
500 <= response.status_code < 600
220-
or response.status_code == 429
221-
) and attempt < self._retries:
215+
if (500 <= response.status_code < 600 or response.status_code == 429) and attempt < self._retries:
222216
sleep_time = self._backoff_factor * (2**attempt)
223217
if response.status_code == 429:
224218
retry_after = response.headers.get("Retry-After")

tmdbfusion/core/sync_client.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,7 @@ def paginate(
215215
self,
216216
method: typing.Callable[..., typing.Any],
217217
*,
218-
map_response: typing.Callable[[typing.Any], list[typing.Any]]
219-
| None = None,
218+
map_response: typing.Callable[[typing.Any], list[typing.Any]] | None = None,
220219
**kwargs: typing.Any,
221220
) -> typing.Iterator[typing.Any]:
222221
"""Paginate through API results.
@@ -296,11 +295,7 @@ def _request(
296295
self._update_rate_limits(response)
297296

298297
# Cache successful GET responses
299-
if (
300-
self._cache
301-
and method == "GET"
302-
and 200 <= response.status_code < 300
303-
) and cache_key:
298+
if (self._cache and method == "GET" and 200 <= response.status_code < 300) and cache_key:
304299
self._cache.set(cache_key, response)
305300

306301
return response

tmdbfusion/data/dataset.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,7 @@ def to_csv(self, path: str) -> None:
204204
writer = csv.DictWriter(f, fieldnames=self.columns)
205205
writer.writeheader()
206206
for row in self.rows:
207-
writer.writerow(
208-
{col: row.data.get(col, "") for col in self.columns}
209-
)
207+
writer.writerow({col: row.data.get(col, "") for col in self.columns})
210208

211209

212210
class DatasetBuilder:

tmdbfusion/data/download.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -457,10 +457,7 @@ async def bulk_posters(
457457
Bulk download results.
458458
459459
"""
460-
tasks = [
461-
self._download_poster(mid, size, skip_existing)
462-
for mid in movie_ids
463-
]
460+
tasks = [self._download_poster(mid, size, skip_existing) for mid in movie_ids]
464461
results = await asyncio.gather(*tasks)
465462

466463
bulk_result = BulkDownloadResult()

tmdbfusion/data/export.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,7 @@ def _apply_field_filter(
154154
if config.include_fields:
155155
data = {k: v for k, v in data.items() if k in config.include_fields}
156156
if config.exclude_fields:
157-
data = {
158-
k: v for k, v in data.items() if k not in config.exclude_fields
159-
}
157+
data = {k: v for k, v in data.items() if k not in config.exclude_fields}
160158
return data
161159

162160

tmdbfusion/exceptions.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,7 @@ class AuthenticationError(TMDBError):
6161
Examples
6262
--------
6363
>>> try:
64-
... raise AuthenticationError(
65-
... 7, "Invalid API key: You must be granted a valid key.", 401
66-
... )
64+
... raise AuthenticationError(7, "Invalid API key: You must be granted a valid key.", 401)
6765
... except AuthenticationError as e:
6866
... print(e)
6967
[7] Invalid API key: You must be granted a valid key.
@@ -103,9 +101,7 @@ class NotFoundError(TMDBError):
103101
Examples
104102
--------
105103
>>> try:
106-
... raise NotFoundError(
107-
... 34, "The resource you requested could not be found.", 404
108-
... )
104+
... raise NotFoundError(34, "The resource you requested could not be found.", 404)
109105
... except NotFoundError as e:
110106
... print(e)
111107
[34] The resource you requested could not be found.

tmdbfusion/features/batch.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,7 @@ class BatchContext:
9797

9898
def __init__(self, concurrency: int = 10) -> None:
9999
self._concurrency = concurrency
100-
self._queue: list[
101-
tuple[Callable[..., object], tuple[object, ...]]
102-
] = []
100+
self._queue: list[tuple[Callable[..., object], tuple[object, ...]]] = []
103101
self._result: BatchResult = BatchResult()
104102

105103
def queue(
@@ -196,9 +194,7 @@ class AsyncBatchContext:
196194

197195
def __init__(self, concurrency: int = 10) -> None:
198196
self._concurrency = concurrency
199-
self._queue: list[
200-
tuple[Callable[..., Awaitable[object]], tuple[object, ...]]
201-
] = []
197+
self._queue: list[tuple[Callable[..., Awaitable[object]], tuple[object, ...]]] = []
202198
self._result: BatchResult = BatchResult()
203199

204200
def queue(
@@ -277,10 +273,7 @@ async def run_one(
277273
except Exception as e: # noqa: BLE001
278274
errors.append((idx, e))
279275

280-
tasks = [
281-
run_one(idx, func, args)
282-
for idx, (func, args) in enumerate(self._queue)
283-
]
276+
tasks = [run_one(idx, func, args) for idx, (func, args) in enumerate(self._queue)]
284277
await asyncio.gather(*tasks)
285278

286279
self._result = BatchResult(results=results, errors=errors)

0 commit comments

Comments
 (0)