Antidote

Latest version: v2.0.0

Safety actively analyzes 630566 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 2 of 5

1.1.1

==================


Bug fix
-------

- Injected functions/methods with :py:func:`.inject` did not behave correctly with
:code:`inspect.isfunction`, :code:`inspect.ismethod`, :code:`inspect.iscoroutinefunction`
and :code:`inspect.iscoroutine`.

1.1.0

==================


Breaking static typing change
-----------------------------

- A function decorated with :py:func:`~.factory.factory` will not have the :code:`` operator
anymore from a static typing perspective. It's unfortunately not possible with the addition of
the class support for the decorator.


Deprecation
-----------

- :py:class:`.Service` and :py:class:`.ABCService` are deprecated in favor of :py:func:`.service`.
- Passing a function to the argument :code:`dependencies` of :py:func:`.inject` is deprecated.
If you want to customize how Antidote injects dependencies, just wrap :py:func:`.inject` instead.
- :py:func:`.inject`'s :code:`auto_provide` argument is deprecated. If you rely on this behavior,
wrap :py:func:`.inject`.
- :code:`world.lazy` is deprecated. It never brought a lot of value, one can easily write it oneself.
- :code:`dependency factory` and :code:`dependency implementation` are replaced by the more explicit
notation:

.. code-block:: python

world.get(dependency, source=factory)

inject(dependencies={'db': Get(dependency, source=factory)})
def (db):
...

- Annotation :code:`Provide` has been renamed :code:`Inject`.
- :code:`world.get` will not support extracting annotated dependencies anymore.
- Omitting the dependency when a type is specified in :code:`world.get` is deprecated. :code:`world.get`
provides now better type information.

.. code-block:: python

from antidote import world, service

service
class Dummy:
pass

this will expose the correct type:
world.get(Dummy)

so this is deprecated
world.get[Dummy]()

you can still specify the type explicitly
world.get[Dummy](Dummy)


Change
------

- Both :code:`world.get` and :code:`const` have better type checking behavior, doing it only when
the specified type is an actual instance of :code:`type`. For protocols, type check will only
be done with those decorated with :code:`typing.runtime_checkable`.
- Dropped Python 3.6 support.


Features
--------

- Add :code:`ignore_type_hints` to :py:func:`.inject` to support cases when type hints cannot be
evaluated, typically in circular imports.
- Adding Markers for :py:func:`.inject` used as default arguments to declare injections:

.. code-block:: python

from antidote import const, Constants, factory, inject, service


class Config(Constants):
HOST = const[str]("host")


service
class Dummy:
value: str


factory
def dummy_factory() -> Dummy:
return Dummy()


inject type hint
inject
def f(dummy: Dummy = inject.me()) -> Dummy:
return dummy


inject type hint with factory
inject
def f2(dummy: Dummy = inject.me(source=dummy_factory)) -> Dummy:
return dummy


inject constants
inject
def f3(host: str = Config.HOST) -> str:
return host


inject a dependency explicitly
inject
def f4(x=inject.get(Dummy)) -> Dummy:
return x


inject a dependency with a factory explicitly
inject
def f5(x=inject.get(Dummy, source=dummy_factory)) -> Dummy:
return x

1.0.1

==================


Change
------

- Update :code:`fastrlock` dependency to :code:`>=0.7,<0.9` to support Python 3.10 for the compiled
version.

1.0.0

==================

No changes. From now on breaking changes will be avoided as much as possible.

0.14.2

===================


Features
--------

- Added :code:`wiring` argument to :py:func:`.service` and auto-wiring like :py:class:`.Service`.

0.14.1

===================


Features
--------

- Added :py:class:`.ABCService` for services to be easier to work with ABC abstract classes.
- Added support for a function in :code:`auto_provide`

Page 2 of 5

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.