Skip to main content

Typed pipe to pipe input into functions.

Project description

typipe

Extremely minimal package which implements a typed pipe. Some convenience functions are also implemented, e.g. a map which is more restricted than the built-in map, but is typed.

Tested with pyright/pylance.

Example:

import typipe as ty
def times_two(x: int) -> int:
    return 2 * x

out: Piped[str] = (
    ty.pipe(253)
    | times_two
    | times_two
    | times_two
    | str
    | ty.tap  # prints 2024
    | (lambda s: f"hello {s}!!")
    | (lambda s: cast(str, s).upper())
)

print(out.get())  # HELLO 2024!!

Note: lambda functions cannot be typed but you can use cast as above to get autocomplete inside the lambda.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

typipe-0.1.2.tar.gz (7.1 kB view hashes)

Uploaded Source

Built Distribution

typipe-0.1.2-py3-none-any.whl (6.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page