Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/duron/_core/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def random(self) -> Random:

"""
assert self._check()
return Random(self._loop.generate_op_id() + self._seed) # noqa: S311
return Random(self._loop.generate_op_id() + self._seed) # ruff: ignore[S311]

@overload
async def complete_future(
Expand Down
10 changes: 5 additions & 5 deletions src/duron/_core/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def init() -> InitParams:
)
self._loop = None
self._lease = None
await self._current_task._start() # pyright: ignore[reportPrivateUsage] # noqa: SLF001
await self._current_task._start() # pyright: ignore[reportPrivateUsage] # ruff: ignore[SLF001]
return self._current_task

async def resume(self, fn: DurableFn[_P, _T]) -> Task[_T]:
Expand Down Expand Up @@ -230,7 +230,7 @@ def init() -> InitParams:
)
self._loop = None
self._lease = None
await self._current_task._start() # pyright: ignore[reportPrivateUsage] # noqa: SLF001
await self._current_task._start() # pyright: ignore[reportPrivateUsage] # ruff: ignore[SLF001]
return self._current_task

async def verify(self, fn: DurableFn[_P, _T]) -> None:
Expand Down Expand Up @@ -260,7 +260,7 @@ def init() -> InitParams:
)
self._loop = None
self._lease = None
if await self._current_task._resume(): # pyright: ignore[reportPrivateUsage] # noqa: SLF001
if await self._current_task._resume(): # pyright: ignore[reportPrivateUsage] # ruff: ignore[SLF001]
return
msg = "Durable function has not completed"
raise RuntimeError(msg)
Expand Down Expand Up @@ -647,7 +647,7 @@ def _handle_message(self, offset: int, e: Entry) -> bool:
try:
result = self._codec.decode_json(e["result"], return_type)
return self._loop.post_completion(id_, result=result)
except Exception as exc: # noqa: BLE001
except Exception as exc: # ruff: ignore[BLE001]
return self._loop.post_completion(id_, exception=exc)
elif "error" in e:
return self._loop.post_completion(
Expand Down Expand Up @@ -705,7 +705,7 @@ async def _task_run(self, id_: str, op: FnCall, op_span: OpSpan | None) -> None:
result = op.callable()
entry["result"] = codec.encode_json(result, op.return_type)
span.set_status("OK")
except (Exception, asyncio.CancelledError) as e: # noqa: BLE001
except (Exception, asyncio.CancelledError) as e: # ruff: ignore[BLE001]
entry["error"] = encode_error(e)
span.set_status("ERROR", str(e))

Expand Down
2 changes: 1 addition & 1 deletion src/duron/_core/signal.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
_T = TypeVar("_T")


class SignalInterrupt(Exception): # noqa: N818
class SignalInterrupt(Exception): # ruff: ignore[N818]
"""Exception raised when a signal interrupts an in-progress operation.

Attributes:
Expand Down
2 changes: 1 addition & 1 deletion src/duron/_core/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@


@final
class StreamClosed(Exception): # noqa: N818
class StreamClosed(Exception): # ruff: ignore[N818]
"""Exception raised when attempting to read from a closed stream.

This exception is raised when a stream consumer tries to get the next value
Expand Down
6 changes: 3 additions & 3 deletions src/duron/_decorator/effect.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ def _check_loop() -> None:
except RuntimeError:
return

from duron.loop import EventLoop # noqa: PLC0415
from duron.loop import EventLoop # ruff: ignore[PLC0415]

if isinstance(loop, EventLoop):
msg = (
"Effects cannot be called from within a duron EventLoop. "
"Use 'ctx.run()' to execute effects."
)
raise RuntimeError(msg) # noqa: TRY004
raise RuntimeError(msg) # ruff: ignore[TRY004]


def _wrap_effect(fn: Callable[_P, Coroutine[Any, Any, _T] | _T]) -> Callable[_P, Any]:
Expand All @@ -59,7 +59,7 @@ async def async_gen_wrapper(
try:
sent = yield value
value = await gen.asend(sent)
except GeneratorExit: # noqa: PERF203
except GeneratorExit: # ruff: ignore[PERF203]
await gen.aclose()
raise
except StopAsyncIteration:
Expand Down
4 changes: 2 additions & 2 deletions src/duron/contrib/codecs.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

import binascii
import pickle # noqa: S403
import pickle # ruff: ignore[S403]
from typing import TYPE_CHECKING, cast
from typing_extensions import Any

Expand All @@ -23,7 +23,7 @@ def decode_json(encoded: JSONValue, _expected_type: TypeHint[Any]) -> object:
if not isinstance(encoded, str):
msg = f"Expected a string, got {type(encoded).__name__}"
raise TypeError(msg)
return pickle.loads(binascii.a2b_base64(encoded.encode())) # noqa: S301
return pickle.loads(binascii.a2b_base64(encoded.encode())) # ruff: ignore[S301]


try:
Expand Down
4 changes: 2 additions & 2 deletions src/duron/contrib/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def _read_entries(self) -> Generator[tuple[int, BaseEntry], None, None]:

async def acquire_lease(self) -> bytes:
async with self._lock:
self._lease = Path(self._log_file).open("ab") # noqa: ASYNC230, SIM115
self._lease = Path(self._log_file).open("ab") # ruff: ignore[ASYNC230, SIM115]
_lock_file(self._lease)
return self._lease.fileno().to_bytes(8, "big")

Expand Down Expand Up @@ -297,7 +297,7 @@ def _read_entries() -> list[tuple[int, BaseEntry]]:
rowid,
cast("BaseEntry", cast("object", entry)),
))
except json.JSONDecodeError: # noqa: PERF203
except json.JSONDecodeError: # ruff: ignore[PERF203]
pass
return results
finally:
Expand Down
24 changes: 12 additions & 12 deletions src/duron/loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def _poll(self, now: int) -> int | None:
deadline: int | None = None
while timers:
ht = timers[0]
if ht._cancelled: # noqa: SLF001
if ht._cancelled: # ruff: ignore[SLF001]
_ = heappop(timers)
elif (t := int(ht.when())) <= now:
_ = heappop(timers)
Expand All @@ -225,28 +225,28 @@ def _poll(self, now: int) -> int | None:

while ready:
h = ready.popleft()
if h._cancelled: # noqa: SLF001
if h._cancelled: # ruff: ignore[SLF001]
continue
h._run() # noqa: SLF001
h._run() # ruff: ignore[SLF001]

def poll_completion(self, task: Future[_T]) -> WaitSet | None:
assert asyncio.get_running_loop() is self._host
self._event.clear()

# hot path - inline task context switch
if prev_task := tasks.current_task():
tasks._leave_task(self._host, prev_task) # noqa: SLF001
events._set_running_loop(self) # noqa: SLF001
tasks._leave_task(self._host, prev_task) # ruff: ignore[SLF001]
events._set_running_loop(self) # ruff: ignore[SLF001]
try:
next_deadline = self._poll(self._now_us)
if task.done():
return None
added, self._added = self._added, []
return WaitSet(added=added, timer=next_deadline, event=self._event)
finally:
events._set_running_loop(self._host) # noqa: SLF001
events._set_running_loop(self._host) # ruff: ignore[SLF001]
if prev_task:
tasks._enter_task(self._host, prev_task) # noqa: SLF001
tasks._enter_task(self._host, prev_task) # ruff: ignore[SLF001]

def pending_ops(self) -> Sequence[OpFuture]:
return tuple(self._ops.values())
Expand Down Expand Up @@ -299,8 +299,8 @@ def is_closed(self) -> bool:
def close(self) -> None:
assert asyncio.get_running_loop() is self._host
if prev_task := tasks.current_task():
tasks._leave_task(self._host, prev_task) # noqa: SLF001
events._set_running_loop(self) # noqa: SLF001
tasks._leave_task(self._host, prev_task) # ruff: ignore[SLF001]
events._set_running_loop(self) # ruff: ignore[SLF001]
try:
_ = self._poll(self._now_us)
to_cancel = (*tasks.all_tasks(), *self._ops.values())
Expand All @@ -324,9 +324,9 @@ def close(self) -> None:
})
self._closed = True
finally:
events._set_running_loop(self._host) # noqa: SLF001
events._set_running_loop(self._host) # ruff: ignore[SLF001]
if prev_task:
tasks._enter_task(self._host, prev_task) # noqa: SLF001
tasks._enter_task(self._host, prev_task) # ruff: ignore[SLF001]

@override
def get_debug(self) -> bool:
Expand Down Expand Up @@ -368,7 +368,7 @@ def _timer_handle_cancelled(self, _th: asyncio.TimerHandle) -> None:
pass


async def create_loop() -> EventLoop: # noqa: RUF029
async def create_loop() -> EventLoop: # ruff: ignore[RUF029]
return EventLoop(asyncio.get_running_loop()) # type: ignore[abstract]


Expand Down
2 changes: 1 addition & 1 deletion src/duron/tracing/_tracer.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ def setup_tracing(
for handler in target_logger.handlers:
if isinstance(handler, _LoggingHandler):
msg = "Logging handler for tracing is already configured."
raise RuntimeError(msg) # noqa: TRY004
raise RuntimeError(msg) # ruff: ignore[TRY004]

handler = _LoggingHandler()
handler.setLevel(level)
Expand Down
Loading
Loading