Releases: Neoteroi/rodi
v2.1.0
-
Improve
resolve()typing, by @sobolevn. -
Use
Selftype for Container, by @sobolevn. -
Improve typing of
inject, by @sobolevn. -
Do not ignore _globalns that is set via
inject(), by @sobolevn. Address an inconsistency:inject(globalsns=...)silently had no effect during class/init resolution even though the parameter was stored — users passing a customglobalsnswould get no error but also no result. The factory path already honoured it, so this brings the two resolution paths into.
parity. -
Drop support for Python <= 3.10.
-
Add Python 3.14 to the build matrix and to classifiers.
-
Remove Codecov from GitHub Workflow and from README.
-
Upgrade type annotations to Python >= 3.10.
-
Remove code checks for Python <= 3.10.
-
Support mixing
__init__parameters and class-level annotated properties for
dependency injection. Previously, when a class defined a custom__init__,
rodi would only inspect constructor parameters and ignore class-level type
annotations. Now both are resolved: constructor parameters are injected as
arguments, and any remaining class-level annotated properties are injected via
setattrafter instantiation. This enables patterns like:class MyService: extra_dep: ExtraDependency # injected via setattr def __init__(self, main_dep: MainDependency) -> None: self.main_dep = main_dep
Resolves issue #43, reported by @lucas-labs.
-
Add support for the decorator pattern
viaContainer.decorate(base_type, decorator_type). The decorator class must have an
__init__parameter whose type annotation matches the registered type; that parameter
receives the inner service instance, while all other parameters are resolved from the
container as usual. Decorators can be chained by callingdecorate()multiple times —
each call wraps the previous registration:container.add_singleton(IGreeter, SimpleGreeter) container.decorate(IGreeter, LoggingGreeter) # wraps SimpleGreeter container.decorate(IGreeter, CachingGreeter) # wraps LoggingGreeter # resolves as: CachingGreeter(LoggingGreeter(SimpleGreeter()))
Resolves issue #15, requested by @Eldar1205.
v2.0.8
- Add the link to the documentation.
- Remove the
UnsupportedUnionTypeExceptionasRodisupports union types,
they only require proper handling.
v2.0.7
- Add the possibility to specify the
ActivationScopeclass when instantiating
theContaineror theServicesobject. This class will be used when
creating scopes. For the issue #55. - Add an experimental class,
TrackingActivationScopeto support nested
scopes transparently, usingcontextvars.ContextVar. For more context, see
the teststest_nested_scope_1,test_nested_scope_2,
test_nested_scope_async_1. For the issue #55. - Raise a
TypeErrorif trying to obtain a service from a disposed scope. - Remove Python 3.8 from the build matrix, add Python 3.13.
- Handle setuptools warning: SetuptoolsDeprecationWarning: License classifiers are deprecated.
v2.0.6
- Fixes import for Protocols support regardless of Python version (partially
broken for Python 3.9), by @fennel-akunesh
v2.0.5
- Adds support for resolving
Protocolclasses even when they don't define an
__init__method, by @lucas-labs - Fixes bug in service provider build logic causing singletons to be instantiated
n times when they are registered after its dependant, by @lucas-labs - Changes the "ignore attributes" logic so that if a class variable has already
been initialized externally, rodi doesn't attempt to reinitialize it (and to
also prevent overriding it if the initialized class variable is also a
registered object), by @lucas-labs
v2.0.4
- Fix bug in Singleton implementation: stop singleton provider from recreating
objects implementing__len__, by @Klavionik - Add Python 3.12 and remove Python 3.7 from the build matrix.
v2.0.3
v2.0.2
- Ignores
ClassVarproperties when resolving dependencies by class annotations. - Marks
rodi2 stable.
v2.0.1
- Removes the strict requirement for resolved classes to have
__init__
methods defined, to add support forProtocols that do not define an
__init__method (thus using*args,**kwargs,
akhundMurad's contribution. - Corrects a code smell, replacing an
icounter withenumerate,
GLEF1X's contribution.
v2.0.0
- Introduces a
ContainerProtocolto improve interoperability between
libraries and alternative implementations of DI containers. The protocol is
inspired by punq, since its code API
is the most user-friendly and intelligible of those that were reviewed.
TheContainerProtocolcan be used through composition
to replacerodiwith alternative implementations of dependency injection in
those libraries that useDI. - Simplifies the code API of the library to support using the
Containerclass
toregisterandresolveservices. The classServicesis still used and
available, but it's no more necessary to use it directly. - Replaces
setup.pywithpyproject.toml. - Renames context classes: "GetServiceContext" to "ActivationScope",
"ResolveContext" to "ResolutionContext". - The "add_exact*" methods have been made private, to simplify the public API.
- Improves type annotations; MaximZayats' contribution.
- Adds typehints to GetServiceContext init params; guscardvs' contribution.
- Adds examples in a dedicated folder. Examples are tested.