in-n-out
plugable dependency injection and result processing
What it is and what it does
in-n-out is a dependency injection framework that uses Python type hints to automatically resolve and provide dependencies to decorated functions. It lets you register provider functions that return instances of specific types, then mark functions with @ino.inject to have those dependencies automatically supplied at call time based on their type annotations. The framework also supports registering result processors—functions that receive and handle return values from injected functions, enabling intentional side effects.
The design emphasizes minimal code changes: you decorate functions and register providers, and the framework handles resolution at runtime. It supports weighted providers (allowing temporary overrides via context managers) and works across Python 3.8–3.12. With no runtime dependencies and low install friction, it's suitable for applications ranging from simple scripts to larger frameworks that need pluggable dependency resolution.
Use it for:
- Inject database connections or configuration objects into handler functions without passing them explicitly
- Register mock providers in tests to override real dependencies without modifying source code
- Build plugin systems where different implementations of a type can be swapped at runtime
- Attach logging or monitoring processors to function results for cross-cutting concerns
- Manage service instances in web frameworks or CLI applications with dependency scoping
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Lightweight dependency injection framework using type hints to automatically resolve and inject dependencies into functions, with optional result processing via registered processors.
Yes, if you need lightweight dependency injection with type-hint-based resolution and minimal overhead. The permissive license, zero runtime dependencies, and active maintenance make it low-risk. However, it's still in Alpha status; evaluate whether the API is stable enough for your use case, and consider that more mature alternatives exist if you need battle-tested production guarantees.
Install
in-n-out on PyPI
pip
pip install in-n-outuv
uv add in-n-outpoetry
poetry add in-n-outInstalling in-n-out
Before you install
Low install friction with no runtime dependencies. Actively maintained as of 2026-08-03 with recent activity, though marked as Alpha status and relatively young (first released 2022-06-30).
License in practice
BSD 3-Clause License is permissive; you can use this in commercial or proprietary projects with minimal restrictions beyond retaining the license notice.
Quickstart
import in_n_out as ino
class Thing:
def __init__(self, name: str):
self.name = name
@ino.inject
def func(thing: Thing):
return thing.name
def give_me_a_thing() -> Thing:
return Thing("Thing")
ino.register_provider(give_me_a_thing)
print(func()) # prints "Thing"
Verify before relying
- Whether the package handles circular dependencies or complex dependency graphs gracefully
- Performance characteristics under high-frequency injection scenarios
- Compatibility with async/await patterns and coroutine injection
Package facts
| License | BSD 3-Clause License (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 844 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 179,778/month — #10,163 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: in_n_out-0.2.1-py3-none-any.whl
Tags
More Application Frameworks packages
FastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
textualTextual is a Python framework for building…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
mcpBuild and connect to Model Context Protocol…
permissive · top 1,000 on PyPI
WerkzeugWerkzeug is a WSGI utility library providing…
permissive · top 1,000 on PyPI
allukaAlluka is a type-based dependency injection…
permissive · top 15,000 on PyPI
dependency-injectorDependency Injector is a dependency injection…
permissive · top 5,000 on PyPI
injectProvides a lightweight dependency injection…
permissive · top 5,000 on PyPI
simple-diA strictly typed dependency injection library…
permissive · top 15,000 on PyPI
lagomLagom is a lightweight dependency injection…
permissive · top 15,000 on PyPI
picoboxPicobox is a lightweight dependency injection…
permissive · top 15,000 on PyPI
injectorInjector is a Python dependency injection…
permissive · top 5,000 on PyPI
gin-configGin provides a lightweight configuration…
permissive · top 15,000 on PyPI
fast-dependsFastDepends provides a standalone dependency…
permissive · top 5,000 on PyPI
pinjectPinject is a dependency injection library that…
permissive · top 15,000 on PyPI