Skip to main content
BasicReturns gives every function in your Python codebase a predictable return structure. Instead of scattered tuples, naked exceptions, or ad-hoc dictionaries, you get two Pydantic-backed models — BasicReturn and DataAndMsgReturn — that express success, failure, messages, and payloads in one unified interface.

Introduction

Understand the problem BasicReturns solves and how its two return types work together.

Quickstart

Install the package and write your first function with a unified return in under five minutes.

Guides

Practical patterns for error handling, chaining operations, and API integration.

API Reference

Full class documentation for BasicReturn and DataAndMsgReturn with all fields and methods.

Why BasicReturns?

Python functions can return anything — a value, a tuple, None, or raise an exception. When a codebase mixes all of these patterns, every call site must guess what it might get back. BasicReturns solves this by providing two lightweight Pydantic models that every function can return instead.

Consistent Shape

Every function returns the same fields — callers always know what to expect.

No Unhandled Exceptions

Capture errors in the error field instead of letting exceptions bubble unpredictably.

Type Safe

Full MyPy compatibility and Pydantic v2 validation out of the box.

Get started in seconds

1

Install from PyPI

2

Import the return types

3

Use in your functions

4

Handle the result uniformly