From 819023e7aa32bb491bf3380a8f927d9f02084840 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=BCdiger=20Busche?= Date: Fri, 16 Oct 2020 19:57:28 +0200 Subject: [PATCH 1/2] Make Configuration.from_ methods accept Path (#300) Co-authored-by: rbusche --- src/dependency_injector/providers.pyi | 9 +++++---- tests/typing/configuration.py | 4 ++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/dependency_injector/providers.pyi b/src/dependency_injector/providers.pyi index 4b4b88d3..01545902 100644 --- a/src/dependency_injector/providers.pyi +++ b/src/dependency_injector/providers.pyi @@ -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: ... diff --git a/tests/typing/configuration.py b/tests/typing/configuration.py index e44eda31..8344b5ac 100644 --- a/tests/typing/configuration.py +++ b/tests/typing/configuration.py @@ -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 From 09d1c4ce9fd144319ce450c2eee8cdc9f19df6cd Mon Sep 17 00:00:00 2001 From: Roman Mogylatov Date: Fri, 16 Oct 2020 14:10:14 -0400 Subject: [PATCH 2/2] Bump versionto 4.0.1 --- docs/main/changelog.rst | 9 +++++++++ src/dependency_injector/__init__.py | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/docs/main/changelog.rst b/docs/main/changelog.rst index 1b5a9cfd..2cac0c41 100644 --- a/docs/main/changelog.rst +++ b/docs/main/changelog.rst @@ -7,6 +7,15 @@ that were made in every particular version. From version 0.7.6 *Dependency Injector* framework strictly follows `Semantic versioning`_ +4.0.1 +----- +- Extend ``Configuration.from_ini()`` and ``Configuration.from_yaml()`` typing stubs to + accept ``pathlib.Path``. The methods were already compatible with ``pathlib.Path`` + and just did not accept it in their signatures (see + `PR 300 `_). Fix + was provided by `JarnoRFB `_. Many thanks to you again, + JarnoRFB. + 4.0.0 ----- New features: diff --git a/src/dependency_injector/__init__.py b/src/dependency_injector/__init__.py index 5f1efe20..65ef6502 100644 --- a/src/dependency_injector/__init__.py +++ b/src/dependency_injector/__init__.py @@ -1,6 +1,6 @@ """Top-level package.""" -__version__ = '4.0.0' +__version__ = '4.0.1' """Version number. :type: str