Skip to content

Add no_item_validation decorator argument to parse and parse_cls#28

Merged
maread99 merged 2 commits into
mainfrom
claude/vibrant-carson-8OGMI
Jun 2, 2026
Merged

Add no_item_validation decorator argument to parse and parse_cls#28
maread99 merged 2 commits into
mainfrom
claude/vibrant-carson-8OGMI

Conversation

@maread99

@maread99 maread99 commented Jun 2, 2026

Copy link
Copy Markdown
Owner

Resolves #6.

Summary

Adds a no_item_validation argument to the parse and parse_cls decorators to skip validation of container items for all parameters, e.g:

@parse(no_item_validation=True)
def f(
    a: list[str],
    b: dict[str, int],
    c: tuple[str, ...],
):
    ...

This has the same effect as including the NO_ITEM_VALIDATION constant to every parameter's Annotated metadata:

@parse
def f(
    a: Annotated[list[str], NO_ITEM_VALIDATION],
    b: Annotated[dict[str, int], NO_ITEM_VALIDATION],
    c: Annotated[tuple[str, ...], NO_ITEM_VALIDATION],
):
    ...

The container types themselves are still validated — only the item-level validation is skipped, at all levels of nesting.

Changes

  • parse and parse_cls now support both the bare (@parse) and called (@parse(...)) forms. When invoked with arguments they return a functools.partial, preserving the existing bare-decorator behaviour.
  • no_item_validation is threaded through validate_against_hints and validates_against_hint (including the Union recursion), reusing the same early-return path as the per-parameter NO_ITEM_VALIDATION constant.
  • Updated the module docstring and the tutorial notebook to document the new argument.

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 format clean, and no new mypy errors introduced.

https://claude.ai/code/session_01Tu9LcAL1F5xrFpJSsEqLc3


Generated by Claude. Manual: fully reviewed and minor revisions made.
Generated by Claude Code

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
@maread99 maread99 added the enhancement New feature or request label Jun 2, 2026
@maread99 maread99 merged commit ec786ec into main Jun 2, 2026
8 checks passed
@maread99 maread99 deleted the claude/vibrant-carson-8OGMI branch June 2, 2026 22:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provide for setting NO_ITEM_VALIDATION at a function level

2 participants