This repository has been archived by the owner on Aug 10, 2024. It is now read-only.
V1.3.0
Deprecation
@service
is deprecated in favor of@injectable
which is a drop-in replacement.@inject
used to raise aRuntimeError
when specifyingignore_type_hints=True
and no injections were found. It now raisesNoInjectionsFoundError
Wiring.wire
used to return the wired class, it won't be the case anymore.
Features
-
Add local type hint support with
type_hints_locals
argument for@inject
,@injectable
,@implements
and@wire
The default behavior can be configured globally withconfig
Auto-detection is done throughinspect
and frame manipulation. It's mostly helpful inside tests.from __future__ import annotations from antidote import config, inject, injectable, world def function() -> None: @injectable class Dummy: pass @inject(type_hints_locals='auto') def f(dummy: Dummy = inject.me()) -> Dummy: return dummy assert f() is world.get(Dummy) function() config.auto_detect_type_hints_locals = True def function2() -> None: @injectable class Dummy: pass @inject def f(dummy: Dummy = inject.me()) -> Dummy: return dummy assert f() is world.get(Dummy) function2()
-
Add
factory_method
to@injectable
(previous@service
)from __future__ import annotations from antidote import injectable @injectable(factory_method='build') class Dummy: @classmethod def build(cls) -> Dummy: return cls()
-
Added
ignore_type_hints
argument toWiring
and@wire
-
Added
type_hints_locals
andclass_in_localns
argument toWiring.wire
Bug fix
- Fix
Optional
detection in predicate constraints.