210 lines
6.1 KiB
Plaintext
210 lines
6.1 KiB
Plaintext
Injector Change Log
|
|
===================
|
|
|
|
0.12.0 (not released yet)
|
|
-------------------------
|
|
|
|
- Fixed binding inference in presence of * and ** arguments (previously Injector
|
|
would generate extra arguments, now it just ignores them)
|
|
- Improved error reporting
|
|
|
|
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.1
|
|
------
|
|
|
|
- 0.11.0 packages uploaded to PyPI are broken (can't be installed), this is
|
|
a fix-only release.
|
|
|
|
0.11.0
|
|
------
|
|
|
|
* The following way to declare dependencies is introduced and recommended
|
|
now:
|
|
|
|
.. code-block:: python
|
|
|
|
class SomeClass:
|
|
@inject
|
|
def __init__(self, other: OtherClass):
|
|
# ...
|
|
|
|
The following ways are still supported but are deprecated and will be
|
|
removed in the future:
|
|
|
|
.. code-block:: python
|
|
|
|
# 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:
|
|
|
|
.. code-block:: python
|
|
|
|
class MyModule(Module):
|
|
@provider
|
|
def provide_something(self, dependency: Dependency) -> Something:
|
|
# ...
|
|
|
|
@provider implies @inject.
|
|
|
|
Previously it would look like this:
|
|
|
|
.. code-block:: python
|
|
|
|
class MyModule(Module):
|
|
@provides(Something)
|
|
@inject
|
|
def provide_something(self, dependency: Dependency):
|
|
# ...
|
|
|
|
The :func:`~injector.provides` decorator will be removed in the future.
|
|
|
|
* Added a :func:`~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 :func:`@inject <injector.inject>`. Previously:
|
|
|
|
.. code-block:: python
|
|
|
|
@inject(something=Something)
|
|
class Class:
|
|
pass
|
|
|
|
Now:
|
|
|
|
.. code-block:: python
|
|
|
|
class Class:
|
|
@inject
|
|
def __init__(self, something: Something):
|
|
self.something = something
|
|
|
|
* Removed support for injecting partially applied functions, previously:
|
|
|
|
.. code-block:: python
|
|
|
|
@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 :class:`AssistedBuilder(callable=...) <injector.AssistedBuilder>`
|
|
* Dropped Python 2.6 support
|
|
* Changed the way :class:`~injector.AssistedBuilder` and :class:`~injector.ProviderOf` are used.
|
|
Previously:
|
|
|
|
.. code-block:: python
|
|
|
|
builder1 = injector.get(AssistedBuilder(Something))
|
|
# or: builder1 = injector.get(AssistedBuilder(interface=Something))
|
|
builder2 = injector.get(AssistedBuilder(cls=SomethingElse))
|
|
provider = injector.get(ProviderOf(SomeOtherThing))
|
|
|
|
Now:
|
|
|
|
.. code-block:: python
|
|
|
|
builder1 = injector.get(AssistedBuilder[Something])
|
|
builder2 = injector.get(ClassAssistedBuilder[cls=SomethingElse])
|
|
provider = injector.get(ProviderOf[SomeOtherThing])
|
|
|
|
* Removed support for injecting into non-constructor methods
|
|
|
|
0.10.1
|
|
------
|
|
|
|
- Fixed a false positive bug in dependency cycle detection (AssistedBuilder can be
|
|
used to break dependency cycles now)
|
|
|
|
0.10.0
|
|
------
|
|
|
|
- :meth:`injector.Provider.get()` now requires an :class:`injector.Injector` instance as
|
|
its parameter
|
|
- deprecated injecting arguments into modules (be it functions/callables,
|
|
:class:`~injector.Module` constructors or :meth:`injector.Module.configure` methods)
|
|
- removed `extends` decorator
|
|
- few classes got useful __repr__ implementations
|
|
- fixed injecting ProviderOf and AssistedBuilders when :class:`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
|
|
|
|
0.9.1
|
|
-----
|
|
- Bug fix release.
|
|
|
|
0.9.0
|
|
-----
|
|
|
|
- Child :class:`~injector.Injector` can rebind dependancies bound in parent Injector (that changes :class:`~injector.Provider` semantics), thanks to Ilya Orlov
|
|
- :class:`~injector.CallableProvider` callables can be injected into, thanks to Ilya Strukov
|
|
- One can request :class:`~injector.ProviderOf` (Interface) and get a :class:`~injector.BoundProvider` which can be used to get an implementation of Interface when needed
|
|
|
|
0.8.0
|
|
-----
|
|
|
|
- Binding annotations are removed. Use :func:`~injector.Key` to create unique types instead.
|
|
|
|
|
|
0.7.9
|
|
-----
|
|
|
|
- Fixed regression with injecting unbound key resulting in None instead of raising an exception
|
|
|
|
|
|
0.7.8
|
|
-----
|
|
|
|
- Exception is raised when :class:`~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 - :class:`~injector.Injector` provides a wrapper that takes care of injecting dependencies into the original function
|
|
|
|
0.7.7
|
|
-----
|
|
|
|
- Made :class:`~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)``
|
|
|
|
0.7.6
|
|
-----
|
|
|
|
- Auto-convert README.md to RST for PyPi.
|
|
|
|
0.7.5
|
|
-----
|
|
|
|
- Added a ChangeLog!
|
|
- Added support for using Python3 annotations as binding types.
|