Welcome to PyDIO’s documentation!
About PyDIO
PyDIO is a dependency injection library for Python.
It aims to be simple, yet still powerful, allowing you to feed dependencies inside your application in a flexible way. PyDIO design is based on simple assumption, that dependency injection can be achieved using simple key-to-function map, where key specifies type of object you want to inject and function is a factory function that creates instances of that type.
In PyDIO, this is implemented using providers and injectors. You use providers to configure your key-to-function mapping, and then you use injectors to perform a lookup of a specific key and creation of the final object.
Here’s a simple example:
import abc
from pydio.api import Provider, Injector
provider = Provider()
@provider.provides('greet')
def make_greet():
return 'Hello, world!'
def main():
injector = Injector(provider)
greet_message = injector.inject('greet')
print(greet_message)
And if you now call main() function, then the output will be following:
Hello, world!
Key features
Support for any hashable keys: class objects, strings, ints etc.
Support for any type of object factories: function, coroutine, generator, asynchronous generator.
Automatic resource management via generator-based factories (similar to pytest’s fixtures)
Multiple environment support: testing, development, production etc.
Limiting created object’s lifetime to user-defined scopes: global, application, use-case etc.
No singletons used, so there is no global state…
…but you still can create global injector on your own if you need it :-)
User’s Guide
- Installation
- Quickstart
- API Reference
- pydio.api
- pydio.base
- pydio.exc
- pydio.injector
- pydio.keys
- pydio.provider
- pydio.v1
- pydio.v1.api
- pydio.v1.async_backends
- pydio.v1.async_backends.asyncio
- pydio.v1.exc
IncompatibleResourceFactoryFoundErrorIncompleteClosingErrorInjectorAlreadyClosedErrorOutOfScopeErrorPyDIOErrorResourceFactoryAlreadyExistsErrorResourceFactoryLookupErrorResourceFactoryNotFoundErrorScopedInjectorAlreadyExistsErrorUserFactoryDeclarationErrorUserFactoryErrorUserFactoryPreconditionError
- pydio.v1.helpers
- pydio.v1.injectors
- pydio.v1.interface
AnyFuncTypeAnyInjectorAsyncBackendLikeAsyncFuncResultAsyncFuncTypeAsyncInjectorLikeAsyncRLockLikeAsyncResourceDisposerLikeAsyncResourceFactoryLikeEnvTypeFuncResultFuncTypeInjectorLikeProviderLikeResourceDisposerLikeResourceFactoryLikeScopeTypeSupportsAsyncInjectSupportsInjectSupportsRegisterFactorySupportsRequireFactoryis_async_resource_disposer()is_async_resource_factory()is_resource_factory()supports_async_inject()supports_inject()
- pydio.v1.providers
- Changelog
- 0.5.3 (2026-10-21)
- 0.5.2 (2026-10-20)
- 0.5.1 (2026-10-20)
- 0.5.0 (2026-10-20)
- 0.4.1 (2023-05-12)
- 0.4.0 (2023-05-06)
- 0.3.3 (2022-11-05)
- 0.3.2 (2022-11-05)
- 0.3.1 (2022-11-05)
- 0.3.0 (2022-11-05)
- 0.2.1 (2022-11-05)
- 0.2.0 (2022-10-30)
- 0.1.0 (2021-02-15)
- 0.1.0 (2021-02-10)
- 0.1.0 (2021-02-04)
- 0.1.0 (2021-02-04)
- 0.1.0 (2021-02-04)
- License