@@ -25,23 +25,23 @@ def with_warn_for_invalid_lines(mappings: Iterator[Binding]) -> Iterator[Binding
25
25
yield mapping
26
26
27
27
28
- class DotEnv () :
28
+ class DotEnv :
29
29
def __init__ (
30
30
self ,
31
31
dotenv_path : Optional [Union [str , os .PathLike ]],
32
32
stream : Optional [IO [str ]] = None ,
33
33
verbose : bool = False ,
34
- encoding : Union [ None , str ] = None ,
34
+ encoding : Optional [ str ] = None ,
35
35
interpolate : bool = True ,
36
36
override : bool = True ,
37
37
) -> None :
38
- self .dotenv_path = dotenv_path # type : Optional[Union[str, os.PathLike]]
39
- self .stream = stream # type : Optional[IO[str]]
40
- self ._dict = None # type : Optional[Dict[str, Optional[str]]]
41
- self .verbose = verbose # type: bool
42
- self .encoding = encoding # type: Union[None, str]
43
- self .interpolate = interpolate # type: bool
44
- self .override = override # type: bool
38
+ self .dotenv_path : Optional [Union [str , os .PathLike ]] = dotenv_path
39
+ self .stream : Optional [IO [str ]] = stream
40
+ self ._dict : Optional [Dict [str , Optional [str ]]] = None
41
+ self .verbose : bool = verbose
42
+ self .encoding : Optional [ str ] = encoding
43
+ self .interpolate : bool = interpolate
44
+ self .override : bool = override
45
45
46
46
@contextmanager
47
47
def _get_stream (self ) -> Iterator [IO [str ]]:
@@ -155,7 +155,7 @@ def set_key(
155
155
an orphan .env somewhere in the filesystem
156
156
"""
157
157
if quote_mode not in ("always" , "auto" , "never" ):
158
- raise ValueError ("Unknown quote_mode: {}" . format ( quote_mode ) )
158
+ raise ValueError (f "Unknown quote_mode: { quote_mode } " )
159
159
160
160
quote = (
161
161
quote_mode == "always"
@@ -167,9 +167,9 @@ def set_key(
167
167
else :
168
168
value_out = value_to_set
169
169
if export :
170
- line_out = 'export {}={}\n ' . format ( key_to_set , value_out )
170
+ line_out = f 'export { key_to_set } ={ value_out } \n '
171
171
else :
172
- line_out = "{ }={}\n ". format ( key_to_set , value_out )
172
+ line_out = f" { key_to_set } ={ value_out } \n "
173
173
174
174
with rewrite (dotenv_path , encoding = encoding ) as (source , dest ):
175
175
replaced = False
@@ -224,14 +224,14 @@ def resolve_variables(
224
224
values : Iterable [Tuple [str , Optional [str ]]],
225
225
override : bool ,
226
226
) -> Mapping [str , Optional [str ]]:
227
- new_values = {} # type : Dict[str, Optional[str]]
227
+ new_values : Dict [str , Optional [str ]] = {}
228
228
229
229
for (name , value ) in values :
230
230
if value is None :
231
231
result = None
232
232
else :
233
233
atoms = parse_variables (value )
234
- env = {} # type : Dict[str, Optional[str]]
234
+ env : Dict [str , Optional [str ]] = {}
235
235
if override :
236
236
env .update (os .environ ) # type: ignore
237
237
env .update (new_values )
0 commit comments