From 398ae48b4b7ac665942799a7b3215efa3776b259 Mon Sep 17 00:00:00 2001 From: Roman Mogylatov Date: Sat, 9 Jul 2022 21:41:29 -0400 Subject: [PATCH] Add typing for .from_json() --- src/dependency_injector/providers.pyi | 2 ++ tests/typing/configuration.py | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/dependency_injector/providers.pyi b/src/dependency_injector/providers.pyi index 66e34e3e..37bc3d6d 100644 --- a/src/dependency_injector/providers.pyi +++ b/src/dependency_injector/providers.pyi @@ -218,6 +218,7 @@ class ConfigurationOption(Provider[Any]): def update(self, value: Any) -> None: ... def from_ini(self, filepath: Union[Path, str], required: bool = False, 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_json(self, filepath: Union[Path, str], required: bool = False, envs_required: bool = False) -> 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_env(self, name: str, default: Optional[Any] = None, required: bool = False, as_: Optional[_Callable[..., Any]] = None) -> None: ... @@ -275,6 +276,7 @@ class Configuration(Object[Any]): def update(self, value: Any) -> None: ... def from_ini(self, filepath: Union[Path, str], required: bool = False, 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_json(self, filepath: Union[Path, str], required: bool = False, envs_required: bool = False) -> 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_env(self, name: str, default: Optional[Any] = None, required: bool = False, as_: Optional[_Callable[..., Any]] = None) -> None: ... diff --git a/tests/typing/configuration.py b/tests/typing/configuration.py index 4a4c7f95..2698dd05 100644 --- a/tests/typing/configuration.py +++ b/tests/typing/configuration.py @@ -15,6 +15,9 @@ config2.from_ini(Path("config.ini")) config2.from_yaml("config.yml") config2.from_yaml(Path("config.yml")) +config2.from_json("config.json") +config2.from_json(Path("config.json")) + config2.from_env("ENV", "default") config2.from_env("ENV", as_=int, default=123) config2.from_env("ENV", as_=float, required=True)