Skip to content

Commit 76ded97

Browse files
committed
Replace "call"/"transform" with "mapping_function"
Also for extra clarity and consistency. Signed-off-by: Leandro Lucarella <[email protected]>
1 parent 9c7a135 commit 76ded97

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/frequenz/channels/_receiver.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ async def receive(self) -> _T_co:
225225
raise ReceiverStoppedError(self) from exc
226226
return received
227227

228-
def map(self, call: Callable[[_T_co], _U_co]) -> Receiver[_U_co]:
228+
def map(self, mapping_function: Callable[[_T_co], _U_co]) -> Receiver[_U_co]:
229229
"""Apply a mapping function on the received message.
230230
231231
Tip:
@@ -235,12 +235,12 @@ def map(self, call: Callable[[_T_co], _U_co]) -> Receiver[_U_co]:
235235
original receiver and use that instead.
236236
237237
Args:
238-
call: The function to be applied on incoming messages.
238+
mapping_function: The function to be applied on incoming messages.
239239
240240
Returns:
241241
A new receiver that applies the function on the received messages.
242242
"""
243-
return _Mapper(self, call)
243+
return _Mapper(self, mapping_function)
244244

245245

246246
class ReceiverError(Error, Generic[_T_co]):
@@ -285,18 +285,18 @@ class _Mapper(Receiver[_U_co], Generic[_T_co, _U_co]):
285285
"""
286286

287287
def __init__(
288-
self, receiver: Receiver[_T_co], transform: Callable[[_T_co], _U_co]
288+
self, receiver: Receiver[_T_co], mapping_function: Callable[[_T_co], _U_co]
289289
) -> None:
290290
"""Initialize this receiver mapper.
291291
292292
Args:
293293
receiver: The input receiver.
294-
transform: The function to apply on the input data.
294+
mapping_function: The function to apply on the input data.
295295
"""
296296
self._receiver: Receiver[_T_co] = receiver
297297
"""The input receiver."""
298298

299-
self._transform: Callable[[_T_co], _U_co] = transform
299+
self._mapping_function: Callable[[_T_co], _U_co] = mapping_function
300300
"""The function to apply on the input data."""
301301

302302
async def ready(self) -> bool:
@@ -324,14 +324,14 @@ def consume(self) -> _U_co: # noqa: DOC502
324324
ReceiverStoppedError: If the receiver stopped producing messages.
325325
ReceiverError: If there is a problem with the receiver.
326326
"""
327-
return self._transform(
327+
return self._mapping_function(
328328
self._receiver.consume()
329329
) # pylint: disable=protected-access
330330

331331
def __str__(self) -> str:
332332
"""Return a string representation of the timer."""
333-
return f"{type(self).__name__}:{self._receiver}:{self._transform}"
333+
return f"{type(self).__name__}:{self._receiver}:{self._mapping_function}"
334334

335335
def __repr__(self) -> str:
336336
"""Return a string representation of the timer."""
337-
return f"{type(self).__name__}({self._receiver!r}, {self._transform!r})"
337+
return f"{type(self).__name__}({self._receiver!r}, {self._mapping_function!r})"

0 commit comments

Comments
 (0)