Skip to content

Commit 9205e87

Browse files
committed
Event: Make the default name more readable
Use underscore separators to format the `id(self)`. Also only use the default if `name` is `None`. Before an empty string would also be changed to the default, but if an user passed an empty string, it is better to leave it untouched. Signed-off-by: Leandro Lucarella <[email protected]>
1 parent 19f503c commit 9205e87

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/frequenz/channels/util/_event.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@ def __init__(self, *, name: str | None = None) -> None:
4949
"""Create a new instance.
5050
5151
Args:
52-
name: The name of the receiver. If `None` the `id(self)` will be used as
53-
the name. This is only for debugging purposes, it will be shown in the
52+
name: The name of the receiver. If `None` an `id(self)`-based name will be
53+
used. This is only for debugging purposes, it will be shown in the
5454
string representation of the receiver.
5555
"""
5656
self._event: _asyncio.Event = _asyncio.Event()
5757
"""The event that is set when the receiver is ready."""
5858

59-
self._name: str = name or str(id(self))
59+
self._name: str = f"{id(self):_}" if name is None else name
6060
"""The name of the receiver.
6161
6262
This is for debugging purposes, it will be shown in the string representation

0 commit comments

Comments
 (0)