Allow extra fields in YAML schema modules, add stricter validation#1050
Allow extra fields in YAML schema modules, add stricter validation#1050nathanjmcdougall merged 12 commits intomainfrom
Conversation
datamodel-code-generator from 0.28.2 to 0.35.0… revert to previous behaviour) and add missing doc comment
Restore addition of "shared" to the Literal annotation in `StepBase.type` to match default
0583a81 to
e7698a2
Compare
CodSpeed Performance ReportMerging #1050 will not alter performanceComparing Summary
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Pull Request Overview
This PR enables extra fields in YAML schema modules by adding extra="allow" to Pydantic model configurations, while also implementing stricter validation and improving roundtripping capabilities. The changes ensure that YAML files can contain additional fields beyond what's defined in the schemas without causing validation errors.
Key changes:
- Added
extra="allow"to all Pydantic BaseModel configurations in schema files - Changed default values from hardcoded defaults to
Nonefor better roundtripping - Added validation error handling with new
PreCommitConfigYAMLConfigError - Updated model dumping calls to include
by_alias=Trueparameter
Reviewed Changes
Copilot reviewed 6 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
tests/usethis/_integrations/pre_commit/test_pre_commit_io_.py |
Added test cases for extra config fields and invalid config validation |
src/usethis/_integrations/pre_commit/schema.py |
Added extra="allow" to all models and changed defaults to None for roundtripping |
src/usethis/_integrations/ci/bitbucket/schema_utils.py |
Updated model dump to include by_alias=True parameter |
src/usethis/_integrations/ci/bitbucket/schema.py |
Added extra="allow" to all models, changed defaults to None, and updated field configurations |
src/usethis/_integrations/ci/bitbucket/pipeweld.py |
Updated model dump JSON to include by_alias=True parameter |
pyproject.toml |
Updated datamodel-code-generator minimum version to 0.35.0 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…thub.com/nathanjmcdougall/usethis-python into 151-how-to-deal-with-out-of-schema-logic
No description provided.