Skip to content

feat: add YAML/TOML/JSON config file loading#69

Merged
maskedsyntax merged 1 commit intomainfrom
feat/config-file-loading
Mar 3, 2026
Merged

feat: add YAML/TOML/JSON config file loading#69
maskedsyntax merged 1 commit intomainfrom
feat/config-file-loading

Conversation

@maskedsyntax
Copy link
Member

@maskedsyntax maskedsyntax commented Mar 3, 2026

Summary

  • Add config_from_dict() to build a HashPrepConfig from a partial nested dict - missing keys fall back to defaults, unknown keys are silently ignored
  • Add hashprep/utils/config_loader.py with load_config(path) supporting .yaml/.yml, .toml, and .json config files
  • Thread config through all 11 check modules: each check now reads thresholds from analyzer.config at call time instead of frozen module-level constants
  • Add config: HashPrepConfig | None = None to DatasetAnalyzer.__init__
  • Add --config PATH CLI option to scan, details, and report commands
  • Export HashPrepConfig and load_config from the top-level hashprep package

Test plan

  • tests/test_config_loader.py 24 new tests: config_from_dict partial overrides, YAML/JSON loading, error cases (missing file, bad extension), and end-to-end threshold overrides via DatasetAnalyzer(config=...)
  • All existing 208 tests continue to pass (232 total)
  • Ruff lint + format checks pass

🤖 Generated with Claude Code

…errides

- Add `config_from_dict()` to config.py for building HashPrepConfig from a
  partial nested dict (unknown keys silently ignored, missing keys use defaults)
- Add `hashprep/utils/config_loader.py` with `load_config(path)` supporting
  .yaml/.yml, .toml, and .json config files
- Add `config: HashPrepConfig | None = None` parameter to DatasetAnalyzer so
  custom configs are respected at analysis time
- Update all 11 check modules to read thresholds from `analyzer.config` at
  call time instead of frozen module-level constants
- Add `--config PATH` option to scan, details, and report CLI commands
- Export `HashPrepConfig` and `load_config` from the top-level `hashprep` package
- Add `tests/test_config_loader.py` with 24 tests covering dict merging,
  YAML/JSON loading, error cases, and end-to-end threshold overrides
- Fix `_FakeAnalyzer` in datetime, statistical_tests, and mutual_info tests
  to include a `config` attribute
@vercel
Copy link

vercel bot commented Mar 3, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
hashprep Ready Ready Preview, Comment Mar 3, 2026 3:12pm

@maskedsyntax maskedsyntax merged commit 1541b12 into main Mar 3, 2026
6 checks passed
@maskedsyntax maskedsyntax deleted the feat/config-file-loading branch March 3, 2026 15:45
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.

1 participant