Skip to content

Commit b776670

Browse files
committed
Add some noqa for exceptions we raise indirectly
There is a new check in `pydoclint` that checks all exceptions in the docs are actually raised directly in the function body, but we sometimes want to document exceptions raised indirectly too. Signed-off-by: Leandro Lucarella <[email protected]>
1 parent 90896d6 commit b776670

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

src/frequenz/channels/_receiver.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,9 @@
164164
class Receiver(ABC, Generic[ReceiverMessageT_co]):
165165
"""An endpoint to receive messages."""
166166

167-
async def __anext__(self) -> ReceiverMessageT_co:
167+
# We need the noqa here because ReceiverError can be raised by ready() and consume()
168+
# implementations.
169+
async def __anext__(self) -> ReceiverMessageT_co: # noqa: DOC503
168170
"""Await the next message in the async iteration over received messages.
169171
170172
Returns:
@@ -215,7 +217,9 @@ def __aiter__(self) -> Self:
215217
"""
216218
return self
217219

218-
async def receive(self) -> ReceiverMessageT_co:
220+
# We need the noqa here because ReceiverError can be raised by consume()
221+
# implementations.
222+
async def receive(self) -> ReceiverMessageT_co: # noqa: DOC503
219223
"""Receive a message.
220224
221225
Returns:

src/frequenz/channels/_select.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,10 @@ def __init__(self, receiver: Receiver[ReceiverMessageT_co], /) -> None:
196196
self._handled: bool = False
197197
"""Flag to indicate if this selected has been handled in the if-chain."""
198198

199+
# We need the noqa here because pydoclint can't figure out raise self._exception
200+
# actually raise an Exception.
199201
@property
200-
def message(self) -> ReceiverMessageT_co:
202+
def message(self) -> ReceiverMessageT_co: # noqa: DOC503
201203
"""The message that was received, if any.
202204
203205
Returns:
@@ -339,7 +341,11 @@ def __init__(self, selected: Selected[ReceiverMessageT_co]) -> None:
339341
# https://github.com/python/mypy/issues/13597
340342

341343

342-
async def select(*receivers: Receiver[Any]) -> AsyncIterator[Selected[Any]]:
344+
# We need the noqa here because BaseExceptionGroup can be raised indirectly by
345+
# _stop_pending_tasks.
346+
async def select( # noqa: DOC503
347+
*receivers: Receiver[Any],
348+
) -> AsyncIterator[Selected[Any]]:
343349
"""Iterate over the messages of all receivers as they receive new messages.
344350
345351
This function is used to iterate over the messages of all receivers as they receive

src/frequenz/channels/timer.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,8 @@ class Timer(Receiver[timedelta]):
466466
depending on the chosen policy.
467467
"""
468468

469-
def __init__( # pylint: disable=too-many-arguments
469+
# We need the noqa here because RuntimeError is raised indirectly.
470+
def __init__( # noqa: DOC503 pylint: disable=too-many-arguments
470471
self,
471472
interval: timedelta,
472473
missed_tick_policy: MissedTickPolicy,
@@ -586,7 +587,8 @@ def is_running(self) -> bool:
586587
"""Whether the timer is running."""
587588
return not self._stopped
588589

589-
def reset(
590+
# We need the noqa here because RuntimeError is raised indirectly.
591+
def reset( # noqa: DOC503
590592
self,
591593
*,
592594
interval: timedelta | None = None,

0 commit comments

Comments
 (0)