async_rx.observable.rx_max   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 6
dl 0
loc 18
rs 10
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A rx_max() 0 11 3
1
from ..protocol import Observable
2
from .rx_reduce import rx_reduce
3
4
__all__ = ["rx_max"]
5
6
7
def rx_max(observable: Observable) -> Observable:
8
    """Create an observable wich returns the maximal item in the source when completes.
9
10
    Args:
11
        observable (observable): the observable source
12
13
    Returns:
14
        (Observable): observable instance
15
16
    """
17
    return rx_reduce(observable=observable, accumulator=lambda a, b: max(a, b) if a else b)
18