Skip to content

Add configuration system with typed loader#4

Merged
zalun merged 5 commits intomainfrom
02-configuration-system
Feb 27, 2026
Merged

Add configuration system with typed loader#4
zalun merged 5 commits intomainfrom
02-configuration-system

Conversation

@zalun
Copy link
Copy Markdown
Owner

@zalun zalun commented Feb 27, 2026

Summary

  • Add config-example.yaml with project configuration template (config.yaml is gitignored)
  • Add src/docproc/config.py — typed Pydantic configuration loader with env var substitution, path resolution, validation, and singleton caching
  • All models use frozen=True and tuple collections for deep immutability
  • 25 tests, 94% coverage

Closes #3

Test plan

  • uv run ruff check src/ tests/ passes
  • uv run ruff format --check src/ tests/ passes
  • uv run ty check src/ passes
  • uv run pytest — 25 tests pass, 94% coverage (≥80% threshold)

🤖 Generated with Claude Code

zalun and others added 5 commits February 27, 2026 10:53
Implements config.yaml and src/docproc/config.py with Pydantic models,
${VAR} environment variable substitution via dotenv, path resolution
against project root, validation, and singleton caching.

Closes #3

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
config.yaml may contain secrets (API keys), so it should not be tracked.
The example file serves as a template for users to copy.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add frozen=True to all Pydantic models for immutability
- Move _config declaration below Config class (forward reference fix)
- Fix singleton cache to only use cache when config_path is None
- Add config file existence check before reading
- Wrap YAML parse errors and Pydantic validation errors with file context
- Handle empty YAML files with clear error message
- Move non-empty recipients check into model via Field(min_length=1)
- Add field_validator for non-blank API key
- Use mock.patch.object in _find_project_root test
- Add tests for blank API key, empty YAML, invalid YAML, missing file
- Add test for _find_project_root success path

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Catch ValidationError specifically instead of broad Exception
- Separate file read from YAML parse for distinct I/O error messages
- Use tuple instead of list for Recipient.tags and Config.recipients
- Add Field(min_length=1) to Recipient.name and Recipient.tags
- Add test for get_config() cold-start auto-load path

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add min_length=1 to all DeepfellowConfig string fields
- Add tags_must_not_contain_blanks validator on Recipient
- Raise RuntimeError if load_config called with path when already loaded
- Wrap _process_env_vars errors with config file path context

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@zalun zalun merged commit b1d0815 into main Feb 27, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Task 02: Configuration System

1 participant