MCPcopy Create free account
hub / github.com/theskumar/python-dotenv / load_dotenv

Function load_dotenv

src/dotenv/main.py:311–346  ·  view source on GitHub ↗

Parse a .env file and then load all the variables found as environment variables. Parameters: dotenv_path: Absolute or relative path to .env file. stream: Text stream (such as `io.StringIO`) with .env content, used if `dotenv_path` is `None`. verbose: Whether

(
    dotenv_path: Optional[StrPath] = None,
    stream: Optional[IO[str]] = None,
    verbose: bool = False,
    override: bool = False,
    interpolate: bool = True,
    encoding: Optional[str] = "utf-8",
)

Source from the content-addressed store, hash-verified

309
310
311def load_dotenv(
312 dotenv_path: Optional[StrPath] = None,
313 stream: Optional[IO[str]] = None,
314 verbose: bool = False,
315 override: bool = False,
316 interpolate: bool = True,
317 encoding: Optional[str] = "utf-8",
318) -> bool:
319 """Parse a .env file and then load all the variables found as environment variables.
320
321 Parameters:
322 dotenv_path: Absolute or relative path to .env file.
323 stream: Text stream (such as `io.StringIO`) with .env content, used if
324 `dotenv_path` is `None`.
325 verbose: Whether to output a warning the .env file is missing.
326 override: Whether to override the system environment variables with the variables
327 from the `.env` file.
328 encoding: Encoding to be used to read the file.
329 Returns:
330 Bool: True if at least one environment variable is set else False
331
332 If both `dotenv_path` and `stream` are `None`, `find_dotenv()` is used to find the
333 .env file.
334 """
335 if dotenv_path is None and stream is None:
336 dotenv_path = find_dotenv()
337
338 dotenv = DotEnv(
339 dotenv_path=dotenv_path,
340 stream=stream,
341 verbose=verbose,
342 interpolate=interpolate,
343 override=override,
344 encoding=encoding,
345 )
346 return dotenv.set_as_environment_variables()
347
348
349def dotenv_values(

Callers 1

dotenvMethod · 0.85

Calls 3

find_dotenvFunction · 0.85
DotEnvClass · 0.85

Tested by

no test coverage detected