Config#
- config: antidote.Config#
Singleton instance of
Config
- class Config#
This class itself shouldn’t be used directly, rely on the singleton
config
instead.Global configuration used by Antidote to (de-)activate features.
- auto_detect_type_hints_locals#
Whether
inject
and all other decorators should rely on inspection to determine automatically the locals fortyping.get_type_hints()
when relying on type hints. Deactivated by default. This behavior can always be overridden by specifyingtype_hints_locals
argument explicitly, either toNone
for deactivation or to'auto'
for activation.It’s mostly interesting during tests. The following example wouldn’t work with string annotations:
>>> from __future__ import annotations >>> from antidote import config, injectable, inject, world >>> config.auto_detect_type_hints_locals = True >>> def dummy_test(): ... with world.test.new(): ... @injectable ... class Dummy: ... pass ... ... @inject ... def f(dummy: Dummy = inject.me()) -> Dummy: ... return dummy ... ... return f() is world.get(Dummy) >>> dummy_test() True