mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2024-11-24 18:43:58 +03:00
Add implementation and typing stub
This commit is contained in:
parent
cc17052acc
commit
93058536e4
File diff suppressed because it is too large
Load Diff
|
@ -205,7 +205,7 @@ class ConfigurationOption(Provider[Any]):
|
||||||
def from_yaml(self, filepath: Union[Path, str], required: bool = False, loader: Optional[Any] = None, envs_required: bool = False) -> None: ...
|
def from_yaml(self, filepath: Union[Path, str], required: bool = False, loader: Optional[Any] = None, envs_required: bool = False) -> None: ...
|
||||||
def from_pydantic(self, settings: PydanticSettings, required: bool = False, **kwargs: Any) -> None: ...
|
def from_pydantic(self, settings: PydanticSettings, required: bool = False, **kwargs: Any) -> None: ...
|
||||||
def from_dict(self, options: _Dict[str, Any], required: bool = False) -> None: ...
|
def from_dict(self, options: _Dict[str, Any], required: bool = False) -> None: ...
|
||||||
def from_env(self, name: str, default: Optional[Any] = None, required: bool = False) -> None: ...
|
def from_env(self, name: str, default: Optional[Any] = None, required: bool = False, as_: Optional[_Callable[..., Any]] = None) -> None: ...
|
||||||
def from_value(self, value: Any) -> None: ...
|
def from_value(self, value: Any) -> None: ...
|
||||||
|
|
||||||
|
|
||||||
|
@ -262,7 +262,7 @@ class Configuration(Object[Any]):
|
||||||
def from_yaml(self, filepath: Union[Path, str], required: bool = False, loader: Optional[Any] = None, envs_required: bool = False) -> None: ...
|
def from_yaml(self, filepath: Union[Path, str], required: bool = False, loader: Optional[Any] = None, envs_required: bool = False) -> None: ...
|
||||||
def from_pydantic(self, settings: PydanticSettings, required: bool = False, **kwargs: Any) -> None: ...
|
def from_pydantic(self, settings: PydanticSettings, required: bool = False, **kwargs: Any) -> None: ...
|
||||||
def from_dict(self, options: _Dict[str, Any], required: bool = False) -> None: ...
|
def from_dict(self, options: _Dict[str, Any], required: bool = False) -> None: ...
|
||||||
def from_env(self, name: str, default: Optional[Any] = None, required: bool = False) -> None: ...
|
def from_env(self, name: str, default: Optional[Any] = None, required: bool = False, as_: Optional[_Callable[..., Any]] = None) -> None: ...
|
||||||
def from_value(self, value: Any) -> None: ...
|
def from_value(self, value: Any) -> None: ...
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1689,7 +1689,7 @@ cdef class ConfigurationOption(Provider):
|
||||||
|
|
||||||
self.override(merge_dicts(current_config, options))
|
self.override(merge_dicts(current_config, options))
|
||||||
|
|
||||||
def from_env(self, name, default=UNDEFINED, required=UNDEFINED):
|
def from_env(self, name, default=UNDEFINED, required=UNDEFINED, as_=UNDEFINED):
|
||||||
"""Load configuration value from the environment variable.
|
"""Load configuration value from the environment variable.
|
||||||
|
|
||||||
:param name: Name of the environment variable.
|
:param name: Name of the environment variable.
|
||||||
|
@ -1701,6 +1701,9 @@ cdef class ConfigurationOption(Provider):
|
||||||
:param required: When required is True, raise an exception if environment variable is undefined.
|
:param required: When required is True, raise an exception if environment variable is undefined.
|
||||||
:type required: bool
|
:type required: bool
|
||||||
|
|
||||||
|
:param as_: Type converter (int, float, etc).
|
||||||
|
:type as_: object
|
||||||
|
|
||||||
:rtype: None
|
:rtype: None
|
||||||
"""
|
"""
|
||||||
value = os.environ.get(name, default)
|
value = os.environ.get(name, default)
|
||||||
|
@ -1711,6 +1714,9 @@ cdef class ConfigurationOption(Provider):
|
||||||
raise ValueError('Environment variable "{0}" is undefined'.format(name))
|
raise ValueError('Environment variable "{0}" is undefined'.format(name))
|
||||||
value = None
|
value = None
|
||||||
|
|
||||||
|
if as_ is not UNDEFINED:
|
||||||
|
value = as_(value)
|
||||||
|
|
||||||
self.override(value)
|
self.override(value)
|
||||||
|
|
||||||
def from_value(self, value):
|
def from_value(self, value):
|
||||||
|
@ -2191,7 +2197,7 @@ cdef class Configuration(Object):
|
||||||
current_config = {}
|
current_config = {}
|
||||||
self.override(merge_dicts(current_config, options))
|
self.override(merge_dicts(current_config, options))
|
||||||
|
|
||||||
def from_env(self, name, default=UNDEFINED, required=UNDEFINED):
|
def from_env(self, name, default=UNDEFINED, required=UNDEFINED, as_=UNDEFINED):
|
||||||
"""Load configuration value from the environment variable.
|
"""Load configuration value from the environment variable.
|
||||||
|
|
||||||
:param name: Name of the environment variable.
|
:param name: Name of the environment variable.
|
||||||
|
@ -2203,6 +2209,9 @@ cdef class Configuration(Object):
|
||||||
:param required: When required is True, raise an exception if environment variable is undefined.
|
:param required: When required is True, raise an exception if environment variable is undefined.
|
||||||
:type required: bool
|
:type required: bool
|
||||||
|
|
||||||
|
:param as_: Type converter (int, float, etc).
|
||||||
|
:type as_: object
|
||||||
|
|
||||||
:rtype: None
|
:rtype: None
|
||||||
"""
|
"""
|
||||||
value = os.environ.get(name, default)
|
value = os.environ.get(name, default)
|
||||||
|
@ -2213,6 +2222,9 @@ cdef class Configuration(Object):
|
||||||
raise ValueError('Environment variable "{0}" is undefined'.format(name))
|
raise ValueError('Environment variable "{0}" is undefined'.format(name))
|
||||||
value = None
|
value = None
|
||||||
|
|
||||||
|
if as_ is not UNDEFINED:
|
||||||
|
value = as_(value)
|
||||||
|
|
||||||
self.override(value)
|
self.override(value)
|
||||||
|
|
||||||
def from_value(self, value):
|
def from_value(self, value):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user