Skip to content

Commit 551bf86

Browse files
TechNiickScirlat DanutKludex
authored
Added type annotations to test_config.py (#2475)
* added type annotations to test_config.py * Apply suggestions from code review --------- Co-authored-by: Scirlat Danut <[email protected]> Co-authored-by: Marcelo Trylesinski <[email protected]>
1 parent 5ab70d8 commit 551bf86

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

tests/test_config.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import typing
23
from pathlib import Path
34
from typing import Any, Optional
45

@@ -39,7 +40,7 @@ def cast_to_int(v: Any) -> int:
3940
config("INT_DEFAULT_STR", cast=int, default="true")
4041

4142

42-
def test_config(tmpdir, monkeypatch):
43+
def test_config(tmpdir: Path, monkeypatch: pytest.MonkeyPatch) -> None:
4344
path = os.path.join(tmpdir, ".env")
4445
with open(path, "w") as file:
4546
file.write("# Do not commit to source control\n")
@@ -52,7 +53,7 @@ def test_config(tmpdir, monkeypatch):
5253

5354
config = Config(path, environ={"DEBUG": "true"})
5455

55-
def cast_to_int(v) -> int:
56+
def cast_to_int(v: typing.Any) -> int:
5657
return int(v)
5758

5859
DEBUG = config("DEBUG", cast=bool)
@@ -104,14 +105,14 @@ def cast_to_int(v) -> int:
104105
config.get("BOOL_AS_INT", cast=bool)
105106

106107

107-
def test_missing_env_file_raises(tmpdir):
108+
def test_missing_env_file_raises(tmpdir: Path) -> None:
108109
path = os.path.join(tmpdir, ".env")
109110

110111
with pytest.raises(FileNotFoundError, match=f"Config file '{path}' not found."):
111112
Config(path)
112113

113114

114-
def test_environ():
115+
def test_environ() -> None:
115116
environ = Environ()
116117

117118
# We can mutate the environ at this point.
@@ -136,7 +137,7 @@ def test_environ():
136137
assert len(environ) == len(os.environ)
137138

138139

139-
def test_config_with_env_prefix(tmpdir, monkeypatch):
140+
def test_config_with_env_prefix(tmpdir: Path, monkeypatch: pytest.MonkeyPatch) -> None:
140141
config = Config(
141142
environ={"APP_DEBUG": "value", "ENVIRONMENT": "dev"}, env_prefix="APP_"
142143
)

0 commit comments

Comments
 (0)