Skip to content

Conversation

sydney-runkle
Copy link
Contributor

Typing support for a signature like the following:

from pydantic import BaseModel, field_validator, ValidatorFunctionWrapHandler
from typing import Any


class A(BaseModel):
    a: int

    @field_validator('a', mode='wrap')
    @classmethod
    def validate_a(cls, value: Any, handler: ValidatorFunctionWrapHandler) -> Any:
        validated = handler(value)
        return validated + 1

@github-actions github-actions bot added the relnotes-fix Used for bugfixes. label Aug 31, 2024
Copy link

cloudflare-workers-and-pages bot commented Aug 31, 2024

Deploying pydantic-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: be8b941
Status: ✅  Deploy successful!
Preview URL: https://c8f02487.pydantic-docs.pages.dev
Branch Preview URL: https://no-info-on-wrap.pydantic-docs.pages.dev

View logs

Copy link

codspeed-hq bot commented Aug 31, 2024

CodSpeed Performance Report

Merging #10277 will not alter performance

Comparing no-info-on-wrap (be8b941) with main (ed55c37)

Summary

✅ 41 untouched benchmarks

@sydney-runkle sydney-runkle added the topic-type checking Related to type checking label Aug 31, 2024
@sydney-runkle sydney-runkle requested a review from Viicos August 31, 2024 16:18
Copy link
Contributor

Coverage report

This PR does not seem to contain any modification to coverable code.

Comment on lines +129 to +135
def invalid_missing_handler(cls, value: Any) -> Any:
"""TODO This shouldn't be valid.

At runtime, `check_decorator_fields_exist` raises an error, as the `handler` argument is missing.
However, there's no type checking error as the provided signature matches
`pydantic_core.core_schema.NoInfoWrapValidatorFunction`.
"""
Copy link
Member

Choose a reason for hiding this comment

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

Ah yes, now I remember this was tricky to handle

@sydney-runkle sydney-runkle merged commit c109563 into main Sep 3, 2024
61 checks passed
@sydney-runkle sydney-runkle deleted the no-info-on-wrap branch September 3, 2024 09:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
relnotes-fix Used for bugfixes. topic-type checking Related to type checking
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants