Settings foundation: Context model + build_context() - #161
Merged
Conversation
Adds a five-tier precedence chain (flag > env > .wiki-toolkit.toml > pyproject.toml > default) for docs_dir, repo_root, branch_prefix, batch_byte_cap, and batch_file_cap, with per-field source tracking. Resolution never raises: malformed files or invalid field values fall through to the next tier. resolve_docs_dir() is left in place for existing callers; later tickets swap them over. Part of #154, closes #156.
model_validate() on a BaseSettings subclass re-triggers its full source pipeline (env/pyproject), so a partial dict with the bad field dropped was still getting the original invalid value merged back in from the live environment/file. Each per-tier settings class now restricts settings_customise_sources to init kwargs only, since the raw dict is already fetched explicitly via the source objects beforehand. Addresses a code-review finding on 156-settings-context-model.
Contributor
|
Version hint: minor Comment ID: Display version hint-auto-generated |
Contributor
|
Relative env-tier paths (docs_dir/repo_root) now resolve against cwd like every other tier, unreadable config files fall through instead of crashing, and a spurious pydantic-settings warning is suppressed. Also consolidates the duplicated pyproject/dedicated-file resolution logic that resolve_docs_dir() and build_context() had drifted apart on, and removes several smaller code duplications flagged in review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Context(pydantic-settings-backed) andbuild_context()towiki_toolkit/settings.py, resolvingdocs_dir,repo_root,branch_prefix,batch_byte_cap,batch_file_capthrough a five-tier precedence chain: CLI flag >WIKI_TOOLKIT_<UPPER_SNAKE>env var > dedicated.wiki-toolkit.toml>pyproject.toml's[tool.wiki_toolkit]table > built-in default, with per-field source tracking.BaseSettings.model_validate()was re-triggering the source pipeline instead of validating a plain dict).resolve_docs_dir()is left in place unchanged;cli.py/doctor.py/write_gate.py/batches.pyare untouched — later tickets swap callers over.Closes #156, part of #154.
Test plan
uv run pytest— 256 passeduv run ruff check/uv run mypyclean