ref: Reformat build_config function

Make the internal function logic a litte clearer
This commit is contained in:
Marty Oehme 2025-11-29 10:53:10 +01:00
parent 9b2dc37279
commit 6517eb3971
Signed by: Marty
GPG key ID: 4E535BC19C61886E

View file

@ -267,17 +267,16 @@ class TConf:
def build_config() -> TConf:
"""Return final configuration object."""
cli = parse_cli()
defaults = {k: opt.default for k, opt in OPTIONS.items()}
env = parse_env()
cli = parse_cli()
rc_path = Path(
cli.get("task_rc") or env.get("task_rc") or OPTIONS["task_rc"].default
).expanduser()
defaults["task_rc"] = rc_path # use XDG-included paths
rc = parse_rc(rc_path) if rc_path.exists() else {}
# we use the 'parsed' XDG-included taskrc locations for defaults
defaults = {k: opt.default for k, opt in OPTIONS.items()}
defaults["task_rc"] = rc_path
merged = defaults | rc | env | cli # later wins
return TConf.from_dict({k: v for k, v in merged.items() if v is not None})