Skip to content

Commit

Permalink
Add an Observable specific overload first with docstring to make pyli…
Browse files Browse the repository at this point in the history
…nt happy.
  • Loading branch information
dbrattli committed May 11, 2019
1 parent 9f19eee commit b9fb578
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 5 deletions.
24 changes: 21 additions & 3 deletions rx/core/observable/observable.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,25 @@ def set_disposable(_: abc.Scheduler = None, __: Any = None):
return Disposable(auto_detach_observer.dispose)

@overload
def pipe(self) -> 'Observable': # pylint: disable=no-self-use
def pipe(self, *operators: Callable[['Observable'], 'Observable']) -> 'Observable': # pylint: disable=no-self-use
"""Compose multiple operators left to right.
Composes zero or more operators into a functional composition.
The operators are composed to right. A composition of zero
operators gives back the original source.
source.pipe() == source
source.pipe(f) == f(source)
source.pipe(g, f) == f(g(source))
source.pipe(h, g, f) == f(g(h(source)))
...
Returns the composed observable.
"""
...

@overload
def pipe(self) -> 'Observable': # pylint: disable=function-redefined, no-self-use
... # pylint: disable=pointless-statement

@overload
Expand Down Expand Up @@ -264,7 +282,7 @@ def pipe(self, # pylint: disable=function-redefined, no-self-use, too-many-argu
... # pylint: disable=pointless-statement

@overload
def pipe(self, # pylint: disable=function-redefined,too-many-arguments,no-self-use
def pipe(self, # pylint: disable=function-redefined, no-self-use, too-many-arguments
op1: Callable[['Observable'], A],
op2: Callable[[A], B],
op3: Callable[[B], C],
Expand All @@ -275,7 +293,7 @@ def pipe(self, # pylint: disable=function-redefined,too-many-arguments,no-self-
... # pylint: disable=pointless-statement

# pylint: disable=function-redefined
def pipe(self, *operators: Callable[['Observable'], Any]) -> Any: # type: ignore
def pipe(self, *operators: Callable[['Observable'], Any]) -> Any:
"""Compose multiple operators left to right.
Composes zero or more operators into a functional composition.
Expand Down
24 changes: 22 additions & 2 deletions rx/core/pipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,27 @@


@overload
def pipe() -> Callable[[A], A]:
def pipe(*operators: Callable[['Observable'], 'Observable']) -> Callable[['Observable'], 'Observable']: # type: ignore
"""Compose multiple operators left to right.
Composes zero or more operators into a functional composition. The
operators are composed to left to right. A composition of zero
operators gives back the source.
Examples:
>>> pipe()(source) == source
>>> pipe(f)(source) == f(source)
>>> pipe(f, g)(source) == g(f(source))
>>> pipe(f, g, h)(source) == h(g(f(source)))
...
Returns:
The composed observable.
"""
...

@overload
def pipe() -> Callable[[A], A]: # pylint: disable=function-redefined
... # pylint: disable=pointless-statement


Expand Down Expand Up @@ -64,7 +84,7 @@ def pipe(op1: Callable[[A], B], # pylint: disable=function-redefined,too-many-a


# pylint: disable=function-redefined
def pipe(*operators: Callable[[Any], Any]) -> Callable[[Any], Any]: # type: ignore
def pipe(*operators: Callable[[Any], Any]) -> Callable[[Any], Any]:
"""Compose multiple operators left to right.
Composes zero or more operators into a functional composition. The
Expand Down

0 comments on commit b9fb578

Please sign in to comment.