load_config

load_config(search_dir: str | Path) StubConfig[source]

Load a StubConfig from the nearest config file.

Searches upward from search_dir for stubpy.toml or a [tool.stubpy] section in pyproject.toml. Returns a default StubConfig when no config file is found.

Parameters:

search_dir (str or Path) – Directory to begin the upward search (typically the package being stubbed, or the current working directory).

Returns:

StubConfig – Fully populated config, falling back to defaults for any key not present in the file.

Examples

>>> from stubpy.config import load_config
>>> cfg = load_config(".")
>>> cfg.union_style in ("modern", "legacy")
True

See also

Public API reference — overview of all public names.