@@ -25,23 +25,23 @@ def with_warn_for_invalid_lines(mappings: Iterator[Binding]) -> Iterator[Binding
2525 yield mapping
2626
2727
28- class DotEnv () :
28+ class DotEnv :
2929 def __init__ (
3030 self ,
3131 dotenv_path : Optional [Union [str , os .PathLike ]],
3232 stream : Optional [IO [str ]] = None ,
3333 verbose : bool = False ,
34- encoding : Union [ None , str ] = None ,
34+ encoding : Optional [ str ] = None ,
3535 interpolate : bool = True ,
3636 override : bool = True ,
3737 ) -> 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
4545
4646 @contextmanager
4747 def _get_stream (self ) -> Iterator [IO [str ]]:
@@ -153,7 +153,7 @@ def set_key(
153153 an orphan .env somewhere in the filesystem
154154 """
155155 if quote_mode not in ("always" , "auto" , "never" ):
156- raise ValueError ("Unknown quote_mode: {}" . format ( quote_mode ) )
156+ raise ValueError (f "Unknown quote_mode: { quote_mode } " )
157157
158158 quote = (
159159 quote_mode == "always"
@@ -165,9 +165,9 @@ def set_key(
165165 else :
166166 value_out = value_to_set
167167 if export :
168- line_out = 'export {}={}\n ' . format ( key_to_set , value_out )
168+ line_out = f 'export { key_to_set } ={ value_out } \n '
169169 else :
170- line_out = "{ }={}\n ". format ( key_to_set , value_out )
170+ line_out = f" { key_to_set } ={ value_out } \n "
171171
172172 with rewrite (dotenv_path , encoding = encoding ) as (source , dest ):
173173 replaced = False
@@ -222,14 +222,14 @@ def resolve_variables(
222222 values : Iterable [Tuple [str , Optional [str ]]],
223223 override : bool ,
224224) -> Mapping [str , Optional [str ]]:
225- new_values = {} # type : Dict[str, Optional[str]]
225+ new_values : Dict [str , Optional [str ]] = {}
226226
227227 for (name , value ) in values :
228228 if value is None :
229229 result = None
230230 else :
231231 atoms = parse_variables (value )
232- env = {} # type : Dict[str, Optional[str]]
232+ env : Dict [str , Optional [str ]] = {}
233233 if override :
234234 env .update (os .environ ) # type: ignore
235235 env .update (new_values )
0 commit comments