8000 Add docstrings to config module (#44) · scientific-python/changelist@137b859 · GitHub
[go: up one dir, main page]

Skip to content

Commit 137b859

Browse files
authored
Add docstrings to config module (#44)
Didn't push them to #30 in time.
1 parent d9ac1e4 commit 137b859

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/changelist/_config.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,11 @@
1010

1111
logger = logging.getLogger(__name__)
1212

13-
here = Path(__file__)
14-
15-
16-
DEFAULT_CONFIG_PATH = here.parent / "default_config.toml"
13+
DEFAULT_CONFIG_PATH = Path(__file__).parent / "default_config.toml"
1714

1815

1916
def remote_config(gh: Github, org_repo: str, *, rev: str):
17+
"""Return configuration options in remote pyproject.toml if they exist."""
2018
repo = gh.get_repo(org_repo)
2119
try:
2220
file = repo.get_contents("pyproject.toml", ref=rev)
@@ -30,6 +28,7 @@ def remote_config(gh: Github, org_repo: str, *, rev: str):
3028

3129

3230
def local_config(path: Path) -> dict:
31+
"""Return configuration options in local TOML file if they exist."""
3332
with path.open("rb") as fp:
3433
config = tomllib.load(fp)
3534
config = config.get("tool", {}).get("changelist", {})
@@ -39,6 +38,11 @@ def local_config(path: Path) -> dict:
3938
def add_config_defaults(
4039
config: dict, *, default_config_path: Path = DEFAULT_CONFIG_PATH
4140
) -> dict:
41+
"""Fill in default config options if they don't exist in `config`.
42+
43+
The options are taken from the TOML file given in `default_config_path`.
44+
Collections such as lists aren't merged.
45+
"""
4246
with default_config_path.open("rb") as fp:
4347
defaults = tomllib.load(fp)
4448
defaults = defaults["tool"]["changelist"]

0 commit comments

Comments
 (0)
0