Add no_item_validation decorator argument to parse and parse_cls#28
Merged
Conversation
Provide for skipping container item validation across all parameters by passing no_item_validation=True to the parse / parse_cls decorators, e.g. @parse(no_item_validation=True). This has the same effect as including the NO_ITEM_VALIDATION constant to every parameter's Annotated metadata. The decorators now support both bare (@parse) and called (@parse(...)) forms. Resolves #6. https://claude.ai/code/session_01Tu9LcAL1F5xrFpJSsEqLc3
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.
Resolves #6.
Summary
Adds a
no_item_validationargument to theparseandparse_clsdecorators to skip validation of container items for all parameters, e.g:This has the same effect as including the
NO_ITEM_VALIDATIONconstant to every parameter'sAnnotatedmetadata:The container types themselves are still validated — only the item-level validation is skipped, at all levels of nesting.
Changes
parseandparse_clsnow support both the bare (@parse) and called (@parse(...)) forms. When invoked with arguments they return afunctools.partial, preserving the existing bare-decorator behaviour.no_item_validationis threaded throughvalidate_against_hintsandvalidates_against_hint(including theUnionrecursion), reusing the same early-return path as the per-parameterNO_ITEM_VALIDATIONconstant.Tests
Added three tests covering:
@parse(no_item_validation=True)skipping item validation across container types (incl. nested containers), while still validating the container types themselves.@parse()(called form, default) still validating items.@parse_cls(no_item_validation=True)behaviour on a dataclass.Full suite passes (
pytest),ruff check/ruff formatclean, and no newmypyerrors introduced.https://claude.ai/code/session_01Tu9LcAL1F5xrFpJSsEqLc3
Generated by Claude. Manual: fully reviewed and minor revisions made.
Generated by Claude Code