quickie.load_env_file

quickie.load_env_file(path: str | Path) dict[str, str]

Load environment variables from a .env file and return them as a dict.

Variables declared without a value (VAR with no =) are omitted; variables with an empty value (VAR=) are kept as empty strings.

This can be used standalone to inspect or forward values:

# _qk/__init__.py — apply .env globally before tasks run
from quickie import app, Context
from quickie.context import load_env_file
from pathlib import Path

_env_path = Path(__file__).parent.parent / ".env"
app.set_context(Context.from_env_file(_env_path))

Or independently, e.g. inside a regular task:

from quickie import task
from quickie.context import load_env_file

@task
def show_db_url():
    env = load_env_file(".env")
    print(env.get("DATABASE_URL"))
Parameters:

path – Path to the .env file. Resolve the path before calling when you need base-directory semantics, e.g. load_env_file(base_dir / ".env").

Returns:

A dict mapping variable names to string values.