Method: flask.cli._env_file_callback
Calls: 20, Exceptions: 0, Paths: 1Back
Path 1: 20 calls (1.0)
Context (20)
Option (20)
None (20)
None (20)
1def _env_file_callback(
2 ctx: click.Context, param: click.Option, value: str | None
3) -> str | None:
4 if value is None:
5 return None
6
7 import importlib
8
9 try:
10 importlib.import_module("dotenv")
11 except ImportError:
12 raise click.BadParameter(
13 "python-dotenv must be installed to load an env file.",
14 ctx=ctx,
15 param=param,
16 ) from None
17
18 # Don't check FLASK_SKIP_DOTENV, that only disables automatically
19 # loading .env and .flaskenv files.
20 load_dotenv(value)
21 return value