NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
PyPI · #2138 most downloaded on PyPI
Injector - Python dependency injection framework, inspired by Guice
Last release 8 months ago
09 Jan 2026
Release timing varies
gaps range from 3 weeks to 1.4 years
Most releases are documented
notes for 36 of 57 stable releases
Nothing withdrawn
no release was ever pulled
16 years old
57 releases · first in 2010
Drop Python 2 wheel support by @davidparsson in #300
AttributeError: __metadata__ on Python 3.13 by @kamyarghajar in #304Full Changelog: 0.23.0...0.24.0
One column per quarter.
__metadata__ attribute. Thanks to Kamyar Ghajar.Allow injecting Annotated types into classes, thanks to Filip Nešťák.
Added:
@provider methods, thanks to Satwik Agrawal.multibind() now accepts types and providers, not just instances. Thanks to Eiríkur Torfason.Backwards incompatible:
scope provided to multibind() applies to the individual bound types, within the collection. Previously the scope was applied to the collection, the list or dict instance. Thanks to Eiríkur Torfason.Let's get these changes released.
Let's get these changes released.
Date: 2024-07-08
Added:
PEP 593 <https://peps.python.org/pep-0593/>_
Annotated <https://docs.python.org/3/library/typing.html#typing.Annotated>_Removed:
Stopped using a deprecated test function, thanks to ljnsn
Added support for PEP 604 union types (Python 3.10+), thanks to David Pärsson
Fixed handling of Union combined with Annotated, thanks to Tobias Nilsson
Backwards incompatible:
Added the license to the source distribution, thanks to Joshua Adelman
Backwards incompatible:
Fixed a bug where only one of multiple NoInject annotations was interpreted
Fixed Python 3.5.3 compatibility
Added remaining type hints to the codebase so that the client code can have better static typing safety
Fixed UnsatisfiedRequirement instantiation (trying to get its string representation would fail)
Removed previously deprecated Key, BindingKey, SequenceKey and MappingKey pseudo-types
Added new public get_bindings function to see what parameters will be injected into a function
Added new generic types using a draft implementation of PEP 593: Inject and NoInject. Those serve as additional ways to declare (non)injectable parameters while inject won't go away any time soon noninjectable may be removed once NoInject is cofirmed to work.
Backwards incompatible:
Removed previously deprecated Key, BindingKey, SequenceKey and MappingKey pseudo-types
Technically backwards incompatible:
Added support for using typing.Dict and typing.List in multibindings. See multibind.
Added multibinding-specific provider variant: multiprovider
Deprecated using provider for multibindings
Fixed failure to provide a default value to a NewType-aliased type with auto_bind enabled
Deprecated Key, SequenceKey and MappingKey – use real types or type aliases instead
Deprecated using single-item lists and dictionaries for multibindings - use real types or type aliases instead
Technically backwards incompatible:
typing.List and typing.Dict specializations are now explicitly disallowed as bind interfaces and types returned by provider-decorated methods
(Re)added support for decorating classes themselves with @inject . This is the same as decorating their constructors. Among other things this gives us
(Re)added support for decorating classes themselves with @inject. This is the same as decorating their constructors. Among other things this gives us dataclasses integration.
Reuploaded to fix incorrectly formatted project description
Removed previously deprecated constructs: with_injector, Injector.install_into, Binder.bind_scope
Backwards incompatible:
Added type information for Injector.create_object() (patch #101 thanks to David Pärsson)
Fixed regression that required all noninjectable parameters to be typed
Passing invalid parameter names to @noninjectable() will now result in an error
Backwards incompatible:
Deprecated with_injector. There's no one migration path recommended, it depends on a particular case.
Fixed a bug with classes deriving from PyQt classes not being able to be instantiated manually (bug #75, patch #76 thanks to David Pärsson)
Fixed a bug with values shared between Injectors in a hierarchy (bugs #52 and #72)
Binder.bind_scope) is no longer necessary and bind_scope is a no-op now.- Improved some error messages
Dropped Injector use_annotations constructor parameter. Whenever @inject is used parameter annotations will be used automatically.
Backwards incompatible:
Nothing published for this version
Technically backwards incompatible:
Technically backwards incompatible:
Forward references as PEP 484 understands them are being resolved now when Python 3-style annotations are used. See https://www.python.org/dev/peps/pep-0484/#forward-references for details.
Optional parameters are treated as compulsory for the purpose of injection.
0.11.0 packages uploaded to PyPI are broken (can't be installed), this is a fix-only release.
The following ways are still supported but are deprecated and will be removed in the future:
The following way to declare dependencies is introduced and recommended now:
class SomeClass:
@inject
def __init__(self, other: OtherClass):
# ...
The following ways are still supported but are deprecated and will be removed in the future:
# Python 2-compatible style
class SomeClass
@inject(other=OtherClass)
def __init__(self, other):
# ...
# Python 3 style without @inject-decoration but with use_annotations
class SomeClass:
def __init__(self, other: OtherClass):
# ...
injector = Injector(use_annotations=True)
# ...
The following way to declare Module provider methods is introduced and recommended now:
class MyModule(Module):
@provider
def provide_something(self, dependency: Dependency) -> Something:
# ...
@provider implies @inject.
Previously it would look like this:
class MyModule(Module):
@provides(Something)
@inject
def provide_something(self, dependency: Dependency):
# ...
The ~injector.provides decorator will be removed in the future.
Added a ~injector.noninjectable decorator to mark parameters as not injectable (this serves as documentation and a way to avoid some runtime errors)
Backwards incompatible:
Removed support for decorating classes with @inject. Previously:
@inject(something=Something)
class Class:
pass
Now:
class Class:
@inject
def __init__(self, something: Something):
self.something = something
Removed support for injecting partially applied functions, previously:
@inject(something=Something)
def some_function(something):
pass
class Class:
@inject(function=some_function)
def __init__(self, function):
# ...
Now you need to move the function with injectable dependencies to a class.
Removed support for getting AssistedBuilder(callable=...)
Dropped Python 2.6 support
Changed the way ~injector.AssistedBuilder and ~injector.ProviderOf are used. Previously:
builder1 = injector.get(AssistedBuilder(Something))
# or: builder1 = injector.get(AssistedBuilder(interface=Something))
builder2 = injector.get(AssistedBuilder(cls=SomethingElse))
provider = injector.get(ProviderOf(SomeOtherThing))
Now:
builder1 = injector.get(AssistedBuilder[Something])
builder2 = injector.get(ClassAssistedBuilder[cls=SomethingElse])
provider = injector.get(ProviderOf[SomeOtherThing])
Removed support for injecting into non-constructor methods
Fixed a false positive bug in dependency cycle detection (AssistedBuilder can be used to break dependency cycles now)
deprecated injecting arguments into modules (be it functions/callables, ~injector.Module constructors or injector.Module.configure methods)
injector.Provider.get() now requires an injector.Injector instance as its parameter
deprecated injecting arguments into modules (be it functions/callables, ~injector.Module constructors or injector.Module.configure methods)
removed extends decorator
few classes got useful __repr__ implementations
fixed injecting ProviderOf and AssistedBuilders when injector.Injector auto_bind is set to False (previously would result in UnsatisfiedRequirement error)
fixed crash occurring when Python 3-function annotation use is enabled and __init__ method has a return value annotation ("injector.UnknownProvider: couldn't determine provider for None to None"), should also apply to free functions as well
- Bug fix release.
Child ~injector.Injector can rebind dependancies bound in parent Injector (that changes ~injector.Provider semantics), thanks to Ilya Orlov
Child ~injector.Injector can rebind dependancies bound in parent Injector (that changes ~injector.Provider semantics), thanks to Ilya Orlov
~injector.CallableProvider callables can be injected into, thanks to Ilya Strukov
One can request ~injector.ProviderOf (Interface) and get a ~injector.BoundProvider which can be used to get an implementation of Interface when needed
Binding annotations are removed. Use ~injector.Key to create unique types instead.
Binding annotations are removed. Use ~injector.Key to create unique types instead.
Exception is raised when ~injector.Injector can't install itself into a class instance due to __slots__ presence
Exception is raised when ~injector.Injector can't install itself into a class instance due to __slots__ presence
Some of exception messages are now more detailed to make debugging easier when injection fails
You can inject functions now - ~injector.Injector provides a wrapper that takes care of injecting dependencies into the original function
Made ~injector.AssistedBuilder behave more explicitly: it can build either innstance of a concrete class (AssistedBuilder(cls=Class)) or it will follo
Made ~injector.AssistedBuilder behave more explicitly: it can build either innstance of a concrete class (AssistedBuilder(cls=Class)) or it will follow Injector bindings (if exist) and construct instance of a class pointed by an interface (AssistedBuilder(interface=Interface)). AssistedBuilder(X) behaviour remains the same, it's equivalent to AssistedBuilder(interface=X)
Auto-convert README.md to RST for PyPi.
Added support for using Python3 annotations as binding types.
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Your coding agent can read these notes before it upgrades. Set up the MCP server →