1
1
import os
2
+ import typing
2
3
from pathlib import Path
3
4
from typing import Any , Optional
4
5
@@ -39,7 +40,7 @@ def cast_to_int(v: Any) -> int:
39
40
config ("INT_DEFAULT_STR" , cast = int , default = "true" )
40
41
41
42
42
- def test_config (tmpdir , monkeypatch ) :
43
+ def test_config (tmpdir : Path , monkeypatch : pytest . MonkeyPatch ) -> None :
43
44
path = os .path .join (tmpdir , ".env" )
44
45
with open (path , "w" ) as file :
45
46
file .write ("# Do not commit to source control\n " )
@@ -52,7 +53,7 @@ def test_config(tmpdir, monkeypatch):
52
53
53
54
config = Config (path , environ = {"DEBUG" : "true" })
54
55
55
- def cast_to_int (v ) -> int :
56
+ def cast_to_int (v : typing . Any ) -> int :
56
57
return int (v )
57
58
58
59
DEBUG = config ("DEBUG" , cast = bool )
@@ -104,14 +105,14 @@ def cast_to_int(v) -> int:
104
105
config .get ("BOOL_AS_INT" , cast = bool )
105
106
106
107
107
- def test_missing_env_file_raises (tmpdir ) :
108
+ def test_missing_env_file_raises (tmpdir : Path ) -> None :
108
109
path = os .path .join (tmpdir , ".env" )
109
110
110
111
with pytest .raises (FileNotFoundError , match = f"Config file '{ path } ' not found." ):
111
112
Config (path )
112
113
113
114
114
- def test_environ ():
115
+ def test_environ () -> None :
115
116
environ = Environ ()
116
117
117
118
# We can mutate the environ at this point.
@@ -136,7 +137,7 @@ def test_environ():
136
137
assert len (environ ) == len (os .environ )
137
138
138
139
139
- def test_config_with_env_prefix (tmpdir , monkeypatch ) :
140
+ def test_config_with_env_prefix (tmpdir : Path , monkeypatch : pytest . MonkeyPatch ) -> None :
140
141
config = Config (
141
142
environ = {"APP_DEBUG" : "value" , "ENVIRONMENT" : "dev" }, env_prefix = "APP_"
142
143
)
0 commit comments