Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: daniel-zullo-frequenz <[email protected]>
Co-authored-by: Sahas Subramanian <[email protected]>
Signed-off-by: Leandro Lucarella <[email protected]>
  • Loading branch information
3 people authored Mar 6, 2024
1 parent b32bf3b commit f603b47
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/frequenz/channels/_broadcast.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def is_closed(self) -> bool:
return self._closed

async def close(self) -> None:
"""Close this Broadcast channel.
"""Close this channel.
Any further attempts to [send()][frequenz.channels.Sender.send] data
will return `False`.
Expand Down Expand Up @@ -277,7 +277,7 @@ def new_receiver(self, *, name: str | None = None, limit: int = 50) -> Receiver[
limit: Number of messages the receiver can hold in its buffer.
Returns:
The new receiver attached to this channel.
A new receiver attached to this channel.
"""
recv: _Receiver[_T] = _Receiver(name, limit, self)
self._receivers[hash(recv)] = weakref.ref(recv)
Expand Down
4 changes: 2 additions & 2 deletions src/frequenz/channels/_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@


class Error(RuntimeError):
"""An error originated in this library.
"""An error that originated in this library.
This is useful if you want to catch all exceptions generated by this library.
"""
Expand All @@ -85,7 +85,7 @@ def __init__(self, message: str):


class ChannelError(Error):
"""An error originated in a channel.
"""An error that originated in a channel.
All exceptions generated by channels inherit from this exception.
"""
Expand Down
2 changes: 1 addition & 1 deletion src/frequenz/channels/_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class Merger(Receiver[_T]):
"""

def __init__(self, *receivers: Receiver[_T], name: str | None) -> None:
"""Iinitialize this merger.
"""Initialize this merger.
Args:
*receivers: The receivers to merge.
Expand Down
8 changes: 4 additions & 4 deletions src/frequenz/channels/_receiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ async def receive(self) -> _T_co:
return received

def map(self, call: Callable[[_T_co], _U_co]) -> Receiver[_U_co]:
"""Map a function on the received values.
"""Apply a mapping function on the received values.
Tip:
The returned receiver type won't have all the methods of the original
Expand All @@ -235,7 +235,7 @@ def map(self, call: Callable[[_T_co], _U_co]) -> Receiver[_U_co]:
original receiver and use that instead.
Args:
call: The function to apply on incoming messages.
call: The function to be applied on incoming messages.
Returns:
A new receiver that applies the function on the received values.
Expand All @@ -244,7 +244,7 @@ def map(self, call: Callable[[_T_co], _U_co]) -> Receiver[_U_co]:


class ReceiverError(Error, Generic[_T_co]):
"""An error originated in a [Receiver][frequenz.channels.Receiver].
"""An error that originated in a [Receiver][frequenz.channels.Receiver].
All exceptions generated by receivers inherit from this exception.
"""
Expand Down Expand Up @@ -322,7 +322,7 @@ def consume(self) -> _U_co: # noqa: DOC502
Raises:
ReceiverStoppedError: If the receiver stopped producing messages.
ReceiverError: If there is some problem with the receiver.
ReceiverError: If there is a problem with the receiver.
"""
return self._transform(
self._receiver.consume()
Expand Down
2 changes: 1 addition & 1 deletion src/frequenz/channels/_select.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def selected_from(


class SelectError(BaseException):
"""An error originated in a [`select()`][frequenz.channels.select] operation.
"""An error that happened during a [`select()`][frequenz.channels.select] operation.
This exception is raised when a `select()` iteration fails. It is raised as
a single exception when one receiver fails during normal operation (while calling
Expand Down
2 changes: 1 addition & 1 deletion src/frequenz/channels/_sender.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ async def send(self, msg: _T_contra) -> None:


class SenderError(Error, Generic[_T_contra]):
"""An error originated in a [Sender][frequenz.channels.Sender].
"""An error that originated in a [Sender][frequenz.channels.Sender].
All exceptions generated by senders inherit from this exception.
"""
Expand Down
2 changes: 1 addition & 1 deletion src/frequenz/channels/timer.py
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ def __str__(self) -> str:
return f"{type(self).__name__}({self.interval})"

def __repr__(self) -> str:
"""Return a string representation of this timer."""
"""Return a string with the internal representation of this timer."""
return (
f"{type(self).__name__}<{self.interval=}, {self.missed_tick_policy=}, "
f"{self.loop=}, {self.is_running=}>"
Expand Down

0 comments on commit f603b47

Please sign in to comment.