Skip to content

Commit e3d27c7

Browse files
fix ruff errors
1 parent 80847d9 commit e3d27c7

3 files changed

Lines changed: 8 additions & 8 deletions

File tree

fastloop/task.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import traceback
33
import uuid
44
from collections.abc import Callable
5+
from contextlib import suppress
56
from datetime import datetime
67
from typing import TYPE_CHECKING, Any
78

@@ -150,10 +151,8 @@ async def stop(self, task_id: str) -> bool:
150151
if not task:
151152
return False
152153
task.cancel()
153-
try:
154+
with suppress(asyncio.CancelledError, TimeoutError):
154155
await asyncio.wait_for(task, timeout=CANCEL_GRACE_PERIOD_S)
155-
except (asyncio.CancelledError, TimeoutError):
156-
pass
157156
return True
158157

159158
async def stop_all(self) -> None:

fastloop/workflow.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ async def on_error(
5959

6060
async def plan(
6161
self,
62-
ctx: "LoopContext",
63-
blocks: list["WorkflowBlock"],
64-
current_block: "WorkflowBlock",
65-
block_output: Any,
62+
_ctx: "LoopContext",
63+
_blocks: list["WorkflowBlock"],
64+
_current_block: "WorkflowBlock",
65+
_block_output: Any,
6666
) -> BlockPlan | dict | None:
6767
"""Override to control block execution order and scheduling.
6868

tests/test_tasks.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import pytest
1010

1111
from fastloop import ExecutorType, FastLoop, RetryPolicy, TaskStatus
12+
from fastloop.exceptions import LoopAlreadyDefinedError
1213
from fastloop.executor import run_in_executor, shutdown_executors
1314
from fastloop.models import TaskState
1415
from fastloop.scheduler import Schedule, validate_cron
@@ -280,7 +281,7 @@ def test_duplicate_task_raises(self):
280281
async def task1() -> str:
281282
return "1"
282283

283-
with pytest.raises(Exception):
284+
with pytest.raises(LoopAlreadyDefinedError):
284285

285286
@app.task(name="dup")
286287
async def task2() -> str:

0 commit comments

Comments
 (0)