returns
Make your functions return something meaningful, typed, and safe!
Decision gist · record as of 2026-08-14
Yes. Returns is actively maintained, has no known vulnerabilities, minimal dependencies, and solves a real problem—making error handling and composition more explicit and type-safe. It is worth installing if you value functional programming patterns, mypy integration, and reducing None/exception-related bugs. The learning curve is moderate; start with Maybe and Result before exploring advanced features.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.11 or later; mypy plugin configuration recommended for full type-safety but not strictly required to run.
- Low friction: pure Python wheel with only typing-extensions as a runtime dependency.
- Actively maintained with a release 12 days ago.
License · maintenance · safety
BSD-3-Clause (permissive) — BSD-3-Clause is permissive; you can use this in commercial and proprietary projects with minimal restrictions, provided you include the license text.
last release 2026-08-02 (12 days)
0 known vulnerabilities (OSV.dev, 2026-08-14) · 1,208,404 downloads/mo, #4,218 on PyPI
Alternatives
Verify before relying
pip install returns
from returns.maybe import Maybe
maybe_value: Maybe[int] = Maybe.from_optional(some_optional)
result = maybe_value.bind_optional(lambda x: x / 2)- Whether the mypy plugin integration is required for full type-checking benefits or optional
- Performance overhead of container wrapping compared to direct exception handling in hot paths
- Compatibility with popular async frameworks beyond the documented Future and FutureResult containers
What it is and what it does
Returns is a functional programming library that replaces common error-handling patterns (None checks, exceptions) with composable container types. It provides Maybe (for optional values), Result (for operations that may fail), RequiresContext (for dependency injection), and IO/Future variants for side effects and async code. All containers are fully typed and checked with mypy, supporting higher-kinded types and enforcing laws through its type system.
The library is designed to make business logic more declarative and testable by encoding control flow into the type system itself. Instead of scattering None checks or try-catch blocks throughout your code, you chain operations using methods like bind, map, and bind_optional, which short-circuit automatically on failure or absence. It works with both sync and async functions and is framework-agnostic.
Use it for
- Replace nested None checks with Maybe.from_optional and chained bind_optional calls for cleaner, more readable pipelines.
- Handle operations that may fail (database queries, API calls) using Result to avoid exception-based control flow.
- Implement typed functional dependency injection with RequiresContext to pass configuration through call stacks without polluting function signatures.
- Structure async code with Future and FutureResult to compose coroutines and handle errors uniformly.
- Write declarative business logic that is easier to test, reason about, and refactor because control flow is explicit in the type system.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
Returns is actively maintained, has no known vulnerabilities, minimal dependencies, and solves a real problem—making error handling and composition more explicit and type-safe. It is worth installing if you value functional programming patterns, mypy integration, and reducing None/exception-related bugs. The learning curve is moderate; start with Maybe and Result before exploring advanced features.
Install
returns on PyPI
Before you install
Low friction: pure Python wheel with only typing-extensions as a runtime dependency. Actively maintained with a release 12 days ago. Supports Python 3.11–3.14.
Requires Python 3.11 or later; mypy plugin configuration recommended for full type-safety but not strictly required to run.
License in practice
BSD-3-Clause is permissive; you can use this in commercial and proprietary projects with minimal restrictions, provided you include the license text.
Quickstart
pip install returns
from returns.maybe import Maybe
maybe_value: Maybe[int] = Maybe.from_optional(some_optional)
result = maybe_value.bind_optional(lambda x: x / 2)
Verify before relying
- Whether the mypy plugin integration is required for full type-checking benefits or optional
- Performance overhead of container wrapping compared to direct exception handling in hot paths
- Compatibility with popular async frameworks beyond the documented Future and FutureResult containers
Package facts
| License | BSD-3-Clause permissive |
| Python support | Supports the current Python release <4.0,>=3.11 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 1 packagetyping-extensions |
| Maintenance | Actively maintained 12 days since the last release |
| First released | |
| Downloads | 1,208,404 / month, #4,218 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 4 - BetaFramework :: HypothesisIntended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Topic :: Software Development :: Libraries :: Python ModulesTopic :: UtilitiesTyping :: Typed |
Evidence: returns-0.29.0-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “monad containers type-safe”
- returnsProvides functional programming primitives—containers like Maybe,…
- oslashOSlash implements functional programming abstractions—functors,…
- wrapsProvides type-safe wrapper types for representing values that may be…
Give your agent the search over MCP, or paste the wish link into any chat.
More Python Modules packages
Converts domain names between Unicode and ASCII-compatible encoding (Punycode) according to IDNA 2008 and Unicode Technical Standard 46, with security validation and broader script coverage than the standard library.
Install it if you work with internationalized domain names, need to validate domains, or use HTTP clients that depend on it transitively.
Setuptools is a Python build backend and package management tool that handles building, distributing, and installing Python packages, including support for C/C++ extension modules.
PyYAML parses and emits YAML 1.1 data format, enabling serialization and deserialization of configuration files and Python objects to and from human-readable YAML text.
Pydantic validates Python data structures against type hints, coercing and checking input at runtime to ensure it matches a declared schema.
Provides reusable metadata objects for use with PEP-593 `typing.Annotated` to express common constraints like bounds, collection sizes, and predicates on types.
Install it if you use or build libraries that need to express type constraints in a standardized, inspectable way—or if you want to annotate your own types with…
Provides runtime tools to inspect and introspect Python type annotations, enabling programmatic examination of type hints at execution time.
See also maybe-else · oslash · wraps · lenses · pyfunctional · classes · testcontainers-core · toolz · testcontainers-postgres · jaraco.functools