BasicReturns gives every function in your Python application a predictable, structured return value. Instead of raising exceptions in some places, returning tuples in others, and usingDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/dev2forge/BasicReturns/llms.txt
Use this file to discover all available pages before exploring further.
None as a sentinel elsewhere, you return a BasicReturn or DataAndMsgReturn object that always carries an ok flag, an optional error, and optional msg and data fields.
Quickstart
Get BasicReturns installed and write your first unified return in under five minutes.
Return Models
Learn about BasicReturn and DataAndMsgReturn — the two classes that power the library.
API Reference
Full class and method signatures extracted from source, with field types and defaults.
Best Practices
Patterns for consistent error handling, operation chaining, and serialisation.
Why BasicReturns?
Python functions return values in many inconsistent ways — raw tuples, bare exceptions,None, custom dicts, or ad-hoc dataclasses. BasicReturns standardises this with two Pydantic-backed models that work identically across every layer of your application.
Consistent Errors
Every function signals success or failure through a single
ok boolean — no exception archaeology required.Rich Context
Attach a human-readable
msg and arbitrary data payload to every return value without inventing new types.Type Safe
Full MyPy compatibility and a
py.typed marker mean your IDE and CI pipeline catch misuse at the type level.Serialisation Ready
to_dict() converts any return object to a plain dictionary, making JSON/API responses trivial.Pydantic v2
Built on Pydantic 2 — validation, coercion, and schema generation come for free.
Python 3.8+
Supports Python 3.8 through 3.12 with no platform restrictions.
Quick Example
quickstart.py
Return structured values from your functions
Instantiate a return model, populate its fields, and return it. Check
response.ok at the call site.