@@ -33,7 +33,7 @@ class empty:
33
33
pass
34
34
35
35
36
- def get_env_value (name : str , required : bool = False , default : Any = empty ) -> str :
36
+ def get_env_value (name : str , required : bool = False , default : Any = empty ) -> str :
37
37
"""
38
38
Core function for extracting the environment variable.
39
39
@@ -56,7 +56,7 @@ def get_env_value(name: str, required: bool=False, default: Any=empty) -> str:
56
56
return value
57
57
58
58
59
- def env_int (name : str , required : bool = False , default : Union [Type [empty ], int ]= empty ) -> int :
59
+ def env_int (name : str , required : bool = False , default : Union [Type [empty ], int ] = empty ) -> int :
60
60
"""Pulls an environment variable out of the environment and casts it to an
61
61
integer. If the name is not present in the environment and no default is
62
62
specified then a ``ValueError`` will be raised. Similarly, if the
@@ -84,7 +84,9 @@ def env_int(name: str, required: bool=False, default: Union[Type[empty], int]=em
84
84
return int (value )
85
85
86
86
87
- def env_float (name : str , required : bool = False , default : Union [Type [empty ], float ]= empty ) -> float :
87
+ def env_float (name : str ,
88
+ required : bool = False ,
89
+ default : Union [Type [empty ], float ] = empty ) -> float :
88
90
"""Pulls an environment variable out of the environment and casts it to an
89
91
float. If the name is not present in the environment and no default is
90
92
specified then a ``ValueError`` will be raised. Similarly, if the
@@ -113,9 +115,9 @@ def env_float(name: str, required: bool=False, default: Union[Type[empty], float
113
115
114
116
115
117
def env_bool (name : str ,
116
- truthy_values : Iterable [Any ]= TRUE_VALUES ,
117
- required : bool = False ,
118
- default : Union [Type [empty ], bool ]= empty ) -> bool :
118
+ truthy_values : Iterable [Any ] = TRUE_VALUES ,
119
+ required : bool = False ,
120
+ default : Union [Type [empty ], bool ] = empty ) -> bool :
119
121
"""Pulls an environment variable out of the environment returning it as a
120
122
boolean. The strings ``'True'`` and ``'true'`` are the default *truthy*
121
123
values. If not present in the environment and no default is specified,
@@ -143,7 +145,7 @@ def env_bool(name: str,
143
145
return value in TRUE_VALUES
144
146
145
147
146
- def env_string (name : str , required : bool = False , default : Union [Type [empty ], str ]= empty ) -> str :
148
+ def env_string (name : str , required : bool = False , default : Union [Type [empty ], str ] = empty ) -> str :
147
149
"""Pulls an environment variable out of the environment returning it as a
148
150
string. If not present in the environment and no default is specified, an
149
151
empty string is returned.
@@ -167,9 +169,9 @@ def env_string(name: str, required: bool=False, default: Union[Type[empty], str]
167
169
168
170
169
171
def env_list (name : str ,
170
- separator : str = ',' ,
171
- required : bool = False ,
172
- default : Union [Type [empty ], List [Any ]]= empty ) -> List [Any ]:
172
+ separator : str = ',' ,
173
+ required : bool = False ,
174
+ default : Union [Type [empty ], List [Any ]] = empty ) -> List [Any ]:
173
175
"""Pulls an environment variable out of the environment, splitting it on a
174
176
separator, and returning it as a list. Extra whitespace on the list values
175
177
is stripped. List values that evaluate as falsy are removed. If not present
@@ -201,9 +203,9 @@ def env_list(name: str,
201
203
202
204
203
205
def get (name : str ,
204
- required : bool = False ,
205
- default : Union [Type [empty ], T ]= empty ,
206
- type : Type [T ]= None ) -> T :
206
+ required : bool = False ,
207
+ default : Union [Type [empty ], T ] = empty ,
208
+ type : Type [T ] = None ) -> T :
207
209
"""Generic getter for environment variables. Handles defaults,
208
210
required-ness, and what type to expect.
209
211
0 commit comments