Skip to content
Back

pyfect

Python

Effect for Python. A program's type says what it returns, how it can fail, and which services it needs, so pyright rejects one that forgets to handle an error or provide a dependency.

Python
Type Safety
Concurrency
Pyright
Open Source

Key features

  • Typed errors, typed dependencies, structured concurrency, layers, streams, and schema, following Effect's model
  • Checked by pyright in strict mode
  • Uses Effect's own test cases as its spec, with over 25,000 tests
  • Covers about 95% of Effect's API so far, tracked in a parity document
  • A pytest plugin with a virtual clock, so a test of a 30-second retry takes no real time
  • Rate limits and circuit breakers per key, in memory or shared through Redis
  • Needs Python 3.13 or later and has one dependency, typing-extensions

pyfect brings Effect to Python. You write a function, and its type records three things: what it returns, the errors it can raise, and the services it needs.

That makes two common mistakes type errors. If a program can fail with UserNotFound and nothing handles it, pyright stops you before the program runs. The same goes for a service nobody provided.

How I know it matches Effect

I used Effect’s own test suite as the spec. pyfect has over 25,000 tests, and one of them fails if any Effect test title is neither ported nor left out with a written reason. A parity document tracks what is done, what is open, and what still differs.

Install

uv add pyfect-dev

The docs are at pyfect.dev and the code is on GitHub under the MIT licence.

Resume (PDF)