mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2024-11-25 11:04:01 +03:00
Make Configuration.from_ methods accept Path (#300)
Co-authored-by: rbusche <rbusche@inserve.de>
This commit is contained in:
parent
39f3f3a623
commit
819023e7aa
|
@ -1,5 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
from typing import (
|
||||
TypeVar,
|
||||
Generic,
|
||||
|
@ -136,8 +137,8 @@ class ConfigurationOption(Provider):
|
|||
def as_float(self) -> TypedConfigurationOption[float]: ...
|
||||
def as_(self, callback: _Callable[..., T], *args: Injection, **kwargs: Injection) -> TypedConfigurationOption[T]: ...
|
||||
def update(self, value: Any) -> None: ...
|
||||
def from_ini(self, filepath: str) -> None: ...
|
||||
def from_yaml(self, filepath: str) -> None: ...
|
||||
def from_ini(self, filepath: Union[Path, str]) -> None: ...
|
||||
def from_yaml(self, filepath: Union[Path, str]) -> None: ...
|
||||
def from_dict(self, options: Dict[str, Any]) -> None: ...
|
||||
def from_env(self, name: str, default: Optional[Any] = None) -> None: ...
|
||||
|
||||
|
@ -157,8 +158,8 @@ class Configuration(Object):
|
|||
def set(self, selector: str, value: Any) -> OverridingContext: ...
|
||||
def reset_cache(self) -> None: ...
|
||||
def update(self, value: Any) -> None: ...
|
||||
def from_ini(self, filepath: str) -> None: ...
|
||||
def from_yaml(self, filepath: str) -> None: ...
|
||||
def from_ini(self, filepath: Union[Path, str]) -> None: ...
|
||||
def from_yaml(self, filepath: Union[Path, str]) -> None: ...
|
||||
def from_dict(self, options: Dict[str, Any]) -> None: ...
|
||||
def from_env(self, name: str, default: Optional[Any] = None) -> None: ...
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
from pathlib import Path
|
||||
from dependency_injector import providers
|
||||
|
||||
|
||||
|
@ -9,7 +10,10 @@ provider1 = providers.Factory(dict, a=config1.a)
|
|||
config2 = providers.Configuration()
|
||||
config2.from_dict({})
|
||||
config2.from_ini('config.ini')
|
||||
config2.from_ini(Path('config.ini'))
|
||||
|
||||
config2.from_yaml('config.yml')
|
||||
config2.from_yaml(Path('config.yml'))
|
||||
config2.from_env('ENV', 'default')
|
||||
|
||||
# Test 3: to check as_*() methods
|
||||
|
|
Loading…
Reference in New Issue
Block a user