Skip to content

Allow extra fields in YAML schema modules, add stricter validation#1050

Merged
nathanjmcdougall merged 12 commits intomainfrom
151-how-to-deal-with-out-of-schema-logic
Oct 27, 2025
Merged

Allow extra fields in YAML schema modules, add stricter validation#1050
nathanjmcdougall merged 12 commits intomainfrom
151-how-to-deal-with-out-of-schema-logic

Conversation

@nathanjmcdougall
Copy link
Copy Markdown
Collaborator

No description provided.

@nathanjmcdougall nathanjmcdougall linked an issue Oct 26, 2025 that may be closed by this pull request
@nathanjmcdougall nathanjmcdougall changed the title Bump datamodel-code-generator from 0.28.2 to 0.35.0 Allow extra fields in YAML schema modules Oct 26, 2025
@nathanjmcdougall nathanjmcdougall changed the title Allow extra fields in YAML schema modules Allow extra fields in YAML schema modules, add stricter validation Oct 26, 2025
@nathanjmcdougall nathanjmcdougall force-pushed the 151-how-to-deal-with-out-of-schema-logic branch from 0583a81 to e7698a2 Compare October 27, 2025 01:39
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Oct 27, 2025

CodSpeed Performance Report

Merging #1050 will not alter performance

Comparing 151-how-to-deal-with-out-of-schema-logic (cc8eca4) with main (6fce804)

Summary

✅ 2 untouched

@codecov
Copy link
Copy Markdown

codecov bot commented Oct 27, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@nathanjmcdougall nathanjmcdougall marked this pull request as ready for review October 27, 2025 02:10
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 None for better roundtripping
  • Added validation error handling with new PreCommitConfigYAMLConfigError
  • Updated model dumping calls to include by_alias=True parameter

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.

@nathanjmcdougall nathanjmcdougall merged commit b95b853 into main Oct 27, 2025
20 checks passed
@nathanjmcdougall nathanjmcdougall deleted the 151-how-to-deal-with-out-of-schema-logic branch October 27, 2025 02:56
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.

How to deal with out-of-schema logic

2 participants