diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b4340c1..f52cf07e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Added + +- The `dotenv_path` argument of `set_key` and `unset_key` now has a type of `Union[str, + os.PathLike]` instead of just `os.PathLike` (#347 by [@bbc2]). + ### Changed - Require Python 3.5 or a later version. Python 2 and 3.4 are no longer supported. (#341 diff --git a/requirements.txt b/requirements.txt index 952bfdce..39302b21 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,6 +7,7 @@ pytest-cov pytest>=3.9 sh>=1.09 tox +types-mock wheel twine portray diff --git a/setup.cfg b/setup.cfg index 9afbc4b3..2723d8a2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -14,6 +14,7 @@ max-line-length = 120 exclude = .tox,.git,docs,venv,.venv [mypy] +check_untyped_defs = true ignore_missing_imports = true [metadata] diff --git a/src/dotenv/main.py b/src/dotenv/main.py index 6b29fc90..d550f6f8 100644 --- a/src/dotenv/main.py +++ b/src/dotenv/main.py @@ -114,7 +114,7 @@ def get_key(dotenv_path: Union[str, _PathLike], key_to_get: str) -> Optional[str @contextmanager -def rewrite(path: _PathLike) -> Iterator[Tuple[IO[str], IO[str]]]: +def rewrite(path: Union[str, _PathLike]) -> Iterator[Tuple[IO[str], IO[str]]]: try: if not os.path.isfile(path): with io.open(path, "w+") as source: @@ -131,7 +131,7 @@ def rewrite(path: _PathLike) -> Iterator[Tuple[IO[str], IO[str]]]: def set_key( - dotenv_path: _PathLike, + dotenv_path: Union[str, _PathLike], key_to_set: str, value_to_set: str, quote_mode: str = "always", @@ -175,7 +175,7 @@ def set_key( def unset_key( - dotenv_path: _PathLike, + dotenv_path: Union[str, _PathLike], key_to_unset: str, quote_mode: str = "always", ) -> Tuple[Optional[bool], str]: diff --git a/tox.ini b/tox.ini index 7c2b4f9d..2cd63024 100644 --- a/tox.ini +++ b/tox.ini @@ -24,7 +24,8 @@ commands = coverage run --parallel -m pytest {posargs} skip_install = true deps = flake8 - mypy<0.900 + mypy + types-mock commands = flake8 src tests mypy --python-version=3.9 src tests