GitHub

Installation

Install pyfect and set up pyright.

pyfect needs Python 3.13 or newer and has no dependencies.

uv add pyfect

The otel extra adds the OpenTelemetry bridge (pyfect.otel):

uv add 'pyfect[otel]'

Type checking

pyright is the type checker pyfect is built for; its inference is what makes errors and services part of the type. Use strict mode, with one setting turned off: pyright infers an unannotated generator's send type as Unknown (pyright#10279), and effect generators never use it.

pyproject.toml
[tool.pyright]
typeCheckingMode = "strict"
reportUnknownParameterType = false

Check it works

hello.py
import pyfect as fx

hello = fx.succeed("world").map(lambda name: f"Hello, {name}!")

assert fx.run_sync(hello) == "Hello, world!"

Next: Effects and generators.