Home / Function/ _env_file_callback() — flask Function Reference

_env_file_callback() — flask Function Reference

Architecture documentation for the _env_file_callback() function in cli.py from the flask codebase.

Entity Profile

Dependency Diagram

graph TD
  b69f640f_f9cb_f4cb_3340_949db6a648e8["_env_file_callback()"]
  a96499c3_f8a9_e782_f156_1c1ee4a86c69["cli.py"]
  b69f640f_f9cb_f4cb_3340_949db6a648e8 -->|defined in| a96499c3_f8a9_e782_f156_1c1ee4a86c69
  2566357e_2f99_c4dc_7c83_f5d07e100474["load_dotenv()"]
  b69f640f_f9cb_f4cb_3340_949db6a648e8 -->|calls| 2566357e_2f99_c4dc_7c83_f5d07e100474
  style b69f640f_f9cb_f4cb_3340_949db6a648e8 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/flask/cli.py lines 493–512

def _env_file_callback(
    ctx: click.Context, param: click.Option, value: str | None
) -> str | None:
    try:
        import dotenv  # noqa: F401
    except ImportError:
        # Only show an error if a value was passed, otherwise we still want to
        # call load_dotenv and show a message without exiting.
        if value is not None:
            raise click.BadParameter(
                "python-dotenv must be installed to load an env file.",
                ctx=ctx,
                param=param,
            ) from None

    # Load if a value was passed, or we want to load default files, or both.
    if value is not None or ctx.obj.load_dotenv_defaults:
        load_dotenv(value, load_defaults=ctx.obj.load_dotenv_defaults)

    return value

Subdomains

Defined In

Frequently Asked Questions

What does _env_file_callback() do?
_env_file_callback() is a function in the flask codebase, defined in src/flask/cli.py.
Where is _env_file_callback() defined?
_env_file_callback() is defined in src/flask/cli.py at line 493.
What does _env_file_callback() call?
_env_file_callback() calls 1 function(s): load_dotenv.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free