Skip to content

Fix compose type annotation and add docstring #202

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion expression/core/compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,19 @@ def starcompose(
...


def starcompose(*fns: Callable[[Any], Any]) -> Callable[[Any], Any]:
def starcompose(*fns: Callable[..., Any]) -> Callable[..., Any]:
"""Compose multiple functions left to right.

Composes zero or more functions into a functional composition. The
functions are composed left to right. A composition of zero
functions gives back the identity function.

The first function must accept a variable number of positional
arguments and if it returns a tuple, the subsequent functions must
accept the same number of arguments as the length of the tuple of
the previous function.
"""

def _compose(source: Any) -> Any:
"""Return a pipeline of composed functions."""
return reduce(lambda fields, f: f(*fields), fns, source)
Expand Down
Loading