Containers¶
uzi.containers
¶
BaseContainer
¶
Bases: _PredicateOpsMixin
_is_anonymous() -> bool
property
¶
True
if this container can be added to the registry or False
if
otherwise.
atomic()
property
abstractmethod
¶
AtomicProEntries
(s)
bases() -> abc.Mapping[Injectable, Provider]
property
abstractmethod
¶
the base container.
providers() -> abc.Mapping[Injectable, Provider]
property
abstractmethod
¶
A mapping of providers registered in the container.
_pro() -> t.Optional[FrozenDict[Self, int]]
property
abstractmethod
¶
The container's provider resolution order.
pro() -> FrozenDict[Self, int]
property
¶
The container's provider resolution order.
Like python's class __mro__
the pro
is computed using
C3 linearization
Returns:
Name | Type | Description |
---|---|---|
pro |
FrozenDict[Container, int]
|
Container
¶
Bases: BaseContainer
, ProviderRegistryMixin
A mapping of dependencies to their providers. We use them to bind dependencies to their providers.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
The container's name |
bases |
tuple[Container]
|
The container's bases |
default_access_modifier |
AccessModifier
|
The default |
__init__(name: str = None, *bases: Self, module: str, access_modifier: AccessModifier = PUBLIC) -> None
¶
Create a container.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
Name of the container |
None
|
*bases |
Container
|
Base container. |
()
|
access_modifier |
AccessModifier
|
The default |
PUBLIC
|
atomic()
property
¶
AtomicProEntries
(s)
extend(*bases: Self) -> Self
¶
Adds containers to extended by this container.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*bases |
Container
|
The base containers to be extended |
()
|
Returns:
Name | Type | Description |
---|---|---|
Self |
Self
|
this container |
access_modifier(accessor: Self)
¶
Get the AccessModifier
Parameters:
Name | Type | Description | Default |
---|---|---|---|
accessor |
Container
|
required |
Returns:
Name | Type | Description |
---|---|---|
access_modifier |
AccessModifier
|
__setitem__(key: Injectable, provider: Provider) -> Self
¶
Register a dependency provider
container[_T] = providers.Value('abc')
Parameters:
Name | Type | Description | Default |
---|---|---|---|
abstract |
Injectable
|
The dependency to be provided |
required |
provider |
Provider
|
The provider to provide the dependency |
required |
Group
¶
_calling_module(depth = 2) -> t.Optional[str]
¶
Get the globals() or locals() scope of the calling scope