U
    nËjör  ã                	   @  sz  U d Z ddlmZ ddlZddlZddlmZ ddlm	Z	 ddl
mZmZmZmZmZmZmZ ddlmZmZ ddlmZ dd	lmZmZmZmZ d
dlmZmZmZ d
dlm Z  d
dl!m"Z" ej#dk rÖddlm$Z$ nddl
m$Z$ ej%Z&ej'f ddiej(—ŽG dd„ dƒƒZ)ej'f ddiej(—ŽG dd„ dƒƒZ*ej'f ddiej(—ŽG dd„ dƒƒZ+ej'f ddiej(—ŽG dd„ dƒƒZ,e�r:G dd„ de$ƒZ-G dd„ de$ƒZ.G dd„ de$ƒZ/G d d!„ d!e$ƒZ0ee.ej1e-ej2f Z3ee0ej4e/ej5f Z6ee7eeef e8eef ee f Z9d"e:d#< ed$ee3e9f d%�Z;ed&ee6e9f d%�Z<ed' Z=d"e:d(< ed)d)d*œd+d+d,d-d.d/d0œd1d2„ƒZ>ed)d)d*œd+d+d3d-d.d4d0œd5d2„ƒZ>ed)d)d6œd+d+d7d-d4d8œd9d2„ƒZ>d:ded;œd+d+d(d-d.d<d0œd=d2„Z>ed>ƒZ?ed?dd@�Z@G dAdB„ dBejAe$e@ ƒZBG dCdD„ dDe$e? ƒZCG dEdF„ dFe$e? ƒZDG dGdH„ dHe$ƒZEG dIdJ„ dJe$ƒZFG dKdL„ dLe$ƒZGG dMdN„ dNe$ƒZHee?ge?f ZIee?ejJge?f ZKeeDe? eCe? f ZLeeGeHeEeFf ZMeeKe? eIe? f ZNed,dOdPœdQdR„ƒZOedSdTdPœdUdR„ƒZOed7dVdPœdWdR„ƒZOdXd.dPœdYdR„ZOedZƒZPe�r*eePd)f ZQnej'f ej(ŽG d[d\„ d\ƒƒZQe�rZeePd)f ZRnej'f ej(ŽG d]d^„ d^ƒƒZRdS )_zBThis module contains related classes and functions for validation.é    )ÚannotationsN)Úpartialmethod)ÚFunctionType)ÚTYPE_CHECKINGÚAnyÚCallableÚTypeVarÚUnionÚcastÚoverload)ÚPydanticUndefinedÚcore_schema)r   )Ú	AnnotatedÚLiteralÚSelfÚ	TypeAliasé   )Ú_decoratorsÚ	_genericsÚ_internal_dataclass)ÚGetCoreSchemaHandler)ÚPydanticUserError)é   é   )ÚProtocolÚfrozenTc                   @  s@   e Zd ZU dZded< ddddœdd	„Zed
ddœdd„ƒZdS )ÚAfterValidatora9  Usage docs: https://docs.pydantic.dev/2.10/concepts/validators/#field-validators

    A metadata class that indicates that a validation should be applied **after** the inner validation logic.

    Attributes:
        func: The validator function.

    Example:
        ```python
        from typing_extensions import Annotated

        from pydantic import AfterValidator, BaseModel, ValidationError

        MyInt = Annotated[int, AfterValidator(lambda v: v + 1)]

        class Model(BaseModel):
            a: MyInt

        print(Model(a=1).a)
        #> 2

        try:
            Model(a='a')
        except ValidationError as e:
            print(e.json(indent=2))
            '''
            [
              {
                "type": "int_parsing",
                "loc": [
                  "a"
                ],
                "msg": "Input should be a valid integer, unable to parse string as an integer",
                "input": "a",
                "url": "https://errors.pydantic.dev/2/v/int_parsing"
              }
            ]
            '''
        ```
    úKcore_schema.NoInfoValidatorFunction | core_schema.WithInfoValidatorFunctionÚfuncr   r   úcore_schema.CoreSchema©Úsource_typeÚhandlerÚreturnc                 C  sX   ||ƒ}t | jdƒ}|r8ttj| jƒ}tj|||jd�S ttj| jƒ}tj||d�S d S )NÚafter)ÚschemaÚ
field_name)r%   )	Ú_inspect_validatorr   r
   r   ÚWithInfoValidatorFunctionZ"with_info_after_validator_functionr&   ÚNoInfoValidatorFunctionZ no_info_after_validator_function)Úselfr!   r"   r%   Úinfo_argr   © r,   úB/tmp/pip-unpacked-wheel-zvl9l234/pydantic/functional_validators.pyÚ__get_pydantic_core_schema__H   s    z+AfterValidator.__get_pydantic_core_schema__ú>_decorators.Decorator[_decorators.FieldValidatorDecoratorInfo]r   ©Ú	decoratorr#   c                 C  s   | |j d�S )N©r   r2   ©Úclsr1   r,   r,   r-   Ú_from_decoratorR   s    zAfterValidator._from_decoratorN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__r.   Úclassmethodr5   r,   r,   r,   r-   r      s
   
)
r   c                   @  sL   e Zd ZU dZded< eZded< ddddœd	d
„Zedddœdd„ƒZ	dS )ÚBeforeValidatorae  Usage docs: https://docs.pydantic.dev/2.10/concepts/validators/#field-validators

    A metadata class that indicates that a validation should be applied **before** the inner validation logic.

    Attributes:
        func: The validator function.
        json_schema_input_type: The input type of the function. This is only used to generate the appropriate
            JSON Schema (in validation mode).

    Example:
        ```python
        from typing_extensions import Annotated

        from pydantic import BaseModel, BeforeValidator

        MyInt = Annotated[int, BeforeValidator(lambda v: v + 1)]

        class Model(BaseModel):
            a: MyInt

        print(Model(a=1).a)
        #> 2

        try:
            Model(a='a')
        except TypeError as e:
            print(e)
            #> can only concatenate str (not "int") to str
        ```
    r   r   r   Újson_schema_input_typer   r   r    c                 C  sv   ||ƒ}| j tkrd n
| | j ¡}t| jdƒ}|rTttj| jƒ}tj|||j	|d�S ttj
| jƒ}tj|||d�S d S )NÚbefore©r%   r&   Újson_schema_input_schema©r%   r@   )r=   r   Úgenerate_schemar'   r   r
   r   r(   Z#with_info_before_validator_functionr&   r)   Z!no_info_before_validator_function©r*   r!   r"   r%   Úinput_schemar+   r   r,   r,   r-   r.   {   s(    ÿ
ýü  ÿz,BeforeValidator.__get_pydantic_core_schema__r/   r   r0   c                 C  s   | |j |jjd�S ©N)r   r=   ©r   Úinfor=   r3   r,   r,   r-   r5   ’   s    þzBeforeValidator._from_decoratorN©
r6   r7   r8   r9   r:   r   r=   r.   r;   r5   r,   r,   r,   r-   r<   W   s   
r<   c                   @  sL   e Zd ZU dZded< eZded< ddddœd	d
„Zedddœdd„ƒZ	dS )ÚPlainValidatora  Usage docs: https://docs.pydantic.dev/2.10/concepts/validators/#field-validators

    A metadata class that indicates that a validation should be applied **instead** of the inner validation logic.

    !!! note
        Before v2.9, `PlainValidator` wasn't always compatible with JSON Schema generation for `mode='validation'`.
        You can now use the `json_schema_input_type` argument to specify the input type of the function
        to be used in the JSON schema when `mode='validation'` (the default). See the example below for more details.

    Attributes:
        func: The validator function.
        json_schema_input_type: The input type of the function. This is only used to generate the appropriate
            JSON Schema (in validation mode). If not provided, will default to `Any`.

    Example:
        ```python
        from typing import Union

        from typing_extensions import Annotated

        from pydantic import BaseModel, PlainValidator

        MyInt = Annotated[
            int,
            PlainValidator(
                lambda v: int(v) + 1, json_schema_input_type=Union[str, int]  # (1)!
            ),
        ]

        class Model(BaseModel):
            a: MyInt

        print(Model(a='1').a)
        #> 2

        print(Model(a=1).a)
        #> 2
        ```

        1. In this example, we've specified the `json_schema_input_type` as `Union[str, int]` which indicates to the JSON schema
        generator that in validation mode, the input type for the `a` field can be either a `str` or an `int`.
    r   r   r   r=   r   r   r    c           	   	   C  s´   ddl m} z.||ƒ}| dtjdd„ || |¡d�¡}W n |k
rR   d }Y nX | | j¡}t| jdƒ}|r’t	tj
| jƒ}tj||j||d�S t	tj| jƒ}tj|||d	�S d S )
Nr   ©ÚPydanticSchemaGenerationErrorÚserializationc                 S  s   || ƒS ©Nr,   ©ÚvÚhr,   r,   r-   Ú<lambda>Ù   ó    z=PlainValidator.__get_pydantic_core_schema__.<locals>.<lambda>)Úfunctionr%   Zreturn_schemaÚplain)r&   rL   r@   )rL   r@   )ÚpydanticrK   Úgetr   Ú#wrap_serializer_function_ser_schemarB   r=   r'   r   r
   r(   Z"with_info_plain_validator_functionr&   r)   Z no_info_plain_validator_function)	r*   r!   r"   rK   r%   rL   rD   r+   r   r,   r,   r-   r.   Ê   s:    ýþ
üýz+PlainValidator.__get_pydantic_core_schema__r/   r   r0   c                 C  s   | |j |jjd�S rE   rF   r3   r,   r,   r-   r5   ô   s    þzPlainValidator._from_decoratorN)
r6   r7   r8   r9   r:   r   r=   r.   r;   r5   r,   r,   r,   r-   rI   š   s   
+*rI   c                   @  sL   e Zd ZU dZded< eZded< ddddœd	d
„Zedddœdd„ƒZ	dS )ÚWrapValidatora¸  Usage docs: https://docs.pydantic.dev/2.10/concepts/validators/#field-validators

    A metadata class that indicates that a validation should be applied **around** the inner validation logic.

    Attributes:
        func: The validator function.
        json_schema_input_type: The input type of the function. This is only used to generate the appropriate
            JSON Schema (in validation mode).

    ```python
    from datetime import datetime

    from typing_extensions import Annotated

    from pydantic import BaseModel, ValidationError, WrapValidator

    def validate_timestamp(v, handler):
        if v == 'now':
            # we don't want to bother with further validation, just return the new value
            return datetime.now()
        try:
            return handler(v)
        except ValidationError:
            # validation failed, in this case we want to return a default value
            return datetime(2000, 1, 1)

    MyTimestamp = Annotated[datetime, WrapValidator(validate_timestamp)]

    class Model(BaseModel):
        a: MyTimestamp

    print(Model(a='now').a)
    #> 2032-01-02 03:04:05.000006
    print(Model(a='invalid').a)
    #> 2000-01-01 00:00:00
    ```
    zScore_schema.NoInfoWrapValidatorFunction | core_schema.WithInfoWrapValidatorFunctionr   r   r=   r   r   r    c                 C  sv   ||ƒ}| j tkrd n
| | j ¡}t| jdƒ}|rTttj| jƒ}tj|||j	|d�S ttj
| jƒ}tj|||d�S d S )NÚwrapr?   rA   )r=   r   rB   r'   r   r
   r   ÚWithInfoWrapValidatorFunctionZ!with_info_wrap_validator_functionr&   ÚNoInfoWrapValidatorFunctionZno_info_wrap_validator_functionrC   r,   r,   r-   r.   '  s(    ÿ
ýüýz*WrapValidator.__get_pydantic_core_schema__r/   r   r0   c                 C  s   | |j |jjd�S rE   rF   r3   r,   r,   r-   r5   @  s    þzWrapValidator._from_decoratorNrH   r,   r,   r,   r-   rX   ü   s   
&rX   c                   @  s   e Zd Zddddœdd„ZdS )Ú_OnlyValueValidatorClsMethodr   ©r4   Úvaluer#   c                C  s   d S rM   r,   ©r*   r4   r^   r,   r,   r-   Ú__call__K  rR   z%_OnlyValueValidatorClsMethod.__call__N©r6   r7   r8   r`   r,   r,   r,   r-   r\   J  s   r\   c                   @  s    e Zd Zdddddœdd„ZdS )Ú_V2ValidatorClsMethodr   ú_core_schema.ValidationInfo©r4   r^   rG   r#   c                C  s   d S rM   r,   ©r*   r4   r^   rG   r,   r,   r-   r`   N  rR   z_V2ValidatorClsMethod.__call__Nra   r,   r,   r,   r-   rb   M  s   rb   c                   @  s    e Zd Zdddddœdd„ZdS )Ú _OnlyValueWrapValidatorClsMethodr   ú)_core_schema.ValidatorFunctionWrapHandler©r4   r^   r"   r#   c                C  s   d S rM   r,   ©r*   r4   r^   r"   r,   r,   r-   r`   Q  rR   z)_OnlyValueWrapValidatorClsMethod.__call__Nra   r,   r,   r,   r-   rf   P  s   rf   c                   @  s"   e Zd Zddddddœdd„ZdS )Ú_V2WrapValidatorClsMethodr   rg   rc   ©r4   r^   r"   rG   r#   c                C  s   d S rM   r,   ©r*   r4   r^   r"   rG   r,   r,   r-   r`   T  s    z"_V2WrapValidatorClsMethod.__call__Nra   r,   r,   r,   r-   rj   S  s   rj   r   Ú_PartialClsOrStaticMethodÚ"_V2BeforeAfterOrPlainValidatorType)ÚboundÚ_V2WrapValidatorType)r>   r$   rY   rT   ÚFieldValidatorModes.)Úcheck_fieldsr=   ÚstrzLiteral['wrap']zbool | Noner   z6Callable[[_V2WrapValidatorType], _V2WrapValidatorType])ÚfieldÚfieldsÚmoderr   r=   r#   c               G  s   d S rM   r,   ©rt   rv   rr   r=   ru   r,   r,   r-   Úfield_validatorv  s    rx   zLiteral[('before', 'plain')]zRCallable[[_V2BeforeAfterOrPlainValidatorType], _V2BeforeAfterOrPlainValidatorType]c               G  s   d S rM   r,   rw   r,   r,   r-   rx   �  s    )rv   rr   zLiteral['after'])rt   ru   rv   rr   r#   c               G  s   d S rM   r,   )rt   rv   rr   ru   r,   r,   r-   rx   Œ  s    r$   )rv   rr   r=   zCallable[[Any], Any]c                 s’   t | tƒrtddd�‚ˆdkr8ˆtk	r8tdˆ›�dd�‚ˆtkrLˆdkrLt‰| fˆ˜‰tdd	„ ˆD ƒƒsttd
dd�‚dddœ‡ ‡‡‡fdd„}|S )a6  Usage docs: https://docs.pydantic.dev/2.10/concepts/validators/#field-validators

    Decorate methods on the class indicating that they should be used to validate fields.

    Example usage:
    ```python
    from typing import Any

    from pydantic import (
        BaseModel,
        ValidationError,
        field_validator,
    )

    class Model(BaseModel):
        a: str

        @field_validator('a')
        @classmethod
        def ensure_foobar(cls, v: Any):
            if 'foobar' not in v:
                raise ValueError('"foobar" not found in a')
            return v

    print(repr(Model(a='this is foobar good')))
    #> Model(a='this is foobar good')

    try:
        Model(a='snap')
    except ValidationError as exc_info:
        print(exc_info)
        '''
        1 validation error for Model
        a
          Value error, "foobar" not found in a [type=value_error, input_value='snap', input_type=str]
        '''
    ```

    For more in depth examples, see [Field Validators](../concepts/validators.md#field-validators).

    Args:
        field: The first field the `field_validator` should be called on; this is separate
            from `fields` to ensure an error is raised if you don't pass at least one.
        *fields: Additional field(s) the `field_validator` should be called on.
        mode: Specifies whether to validate the fields before or after validation.
        check_fields: Whether to check that the fields actually exist on the model.
        json_schema_input_type: The input type of the function. This is only used to generate
            the appropriate JSON Schema (in validation mode) and can only specified
            when `mode` is either `'before'`, `'plain'` or `'wrap'`.

    Returns:
        A decorator that can be used to decorate a function to be used as a field_validator.

    Raises:
        PydanticUserError:
            - If `@field_validator` is used bare (with no fields).
            - If the args passed to `@field_validator` as fields are not strings.
            - If `@field_validator` applied to instance methods.
    z…`@field_validator` should be used with fields and keyword arguments, not bare. E.g. usage should be `@validator('<field_name>', ...)`zvalidator-no-fields©Úcode)r>   rT   rY   z;`json_schema_input_type` can't be used when mode is set to zvalidator-input-typerT   c                 s  s   | ]}t |tƒV  qd S rM   )Ú
isinstancers   )Ú.0rt   r,   r,   r-   Ú	<genexpr>ê  s     z"field_validator.<locals>.<genexpr>zŽ`@field_validator` fields should be passed as separate string args. E.g. usage should be `@validator('<field_name_1>', '<field_name_2>', ...)`zvalidator-invalid-fieldszHCallable[..., Any] | staticmethod[Any, Any] | classmethod[Any, Any, Any]ú(_decorators.PydanticDescriptorProxy[Any]©Úfr#   c                   s>   t  | ¡rtddd�‚t  | ¡} t jˆˆˆ ˆd�}t  | |¡S )Nz8`@field_validator` cannot be applied to instance methodszvalidator-instance-methodry   )ru   rv   rr   r=   )r   Zis_instance_method_from_sigr   Ú%ensure_classmethod_based_on_signatureZFieldValidatorDecoratorInfoÚPydanticDescriptorProxy©r€   Zdec_info©rr   ru   r=   rv   r,   r-   Údecñ  s    
 ÿ
   ÿzfield_validator.<locals>.dec)r{   r   r   r   r   Úall)rt   rv   rr   r=   ru   r…   r,   r„   r-   rx   –  s(    C
ýþ
ýÚ
_ModelTypeÚ_ModelTypeCo)Ú	covariantc                   @  s$   e Zd ZdZd	ddddœdd„ZdS )
ÚModelWrapValidatorHandlerz]`@model_validator` decorated function handler argument type. This is used when `mode='wrap'`.Nr   zstr | int | Nonerˆ   )r^   Úouter_locationr#   c                C  s   d S rM   r,   )r*   r^   r‹   r,   r,   r-   r`     s    z"ModelWrapValidatorHandler.__call__)N©r6   r7   r8   r9   r`   r,   r,   r,   r-   rŠ     s    ýrŠ   c                   @  s$   e Zd ZdZdddddœdd„Zd	S )
ÚModelWrapValidatorWithoutInfoz‰A `@model_validator` decorated function signature.
    This is used when `mode='wrap'` and the function does not have info argument.
    útype[_ModelType]r   ú%ModelWrapValidatorHandler[_ModelType]r‡   rh   c                C  s   d S rM   r,   ri   r,   r,   r-   r`     s    	z&ModelWrapValidatorWithoutInfo.__call__NrŒ   r,   r,   r,   r-   r�     s   r�   c                   @  s&   e Zd ZdZddddddœdd	„Zd
S )ÚModelWrapValidatorzSA `@model_validator` decorated function signature. This is used when `mode='wrap'`.rŽ   r   r�   rc   r‡   rk   c                C  s   d S rM   r,   rl   r,   r,   r-   r`   (  s    
zModelWrapValidator.__call__NrŒ   r,   r,   r,   r-   r�   %  s   r�   c                   @  s    e Zd ZdZdddœdd„ZdS )Ú#FreeModelBeforeValidatorWithoutInfoú‹A `@model_validator` decorated function signature.
    This is used when `mode='before'` and the function does not have info argument.
    r   )r^   r#   c                C  s   d S rM   r,   )r*   r^   r,   r,   r-   r`   :  s    z,FreeModelBeforeValidatorWithoutInfo.__call__NrŒ   r,   r,   r,   r-   r‘   5  s   r‘   c                   @  s"   e Zd ZdZddddœdd„ZdS )ÚModelBeforeValidatorWithoutInfor’   r   r]   c                C  s   d S rM   r,   r_   r,   r,   r-   r`   I  s    z(ModelBeforeValidatorWithoutInfo.__call__NrŒ   r,   r,   r,   r-   r“   D  s   r“   c                   @  s"   e Zd ZdZddddœdd„ZdS )ÚFreeModelBeforeValidatorúUA `@model_validator` decorated function signature. This is used when `mode='before'`.r   rc   )r^   rG   r#   c                C  s   d S rM   r,   )r*   r^   rG   r,   r,   r-   r`   W  s    z!FreeModelBeforeValidator.__call__NrŒ   r,   r,   r,   r-   r”   T  s   r”   c                   @  s$   e Zd ZdZdddddœdd„ZdS )ÚModelBeforeValidatorr•   r   rc   rd   c                C  s   d S rM   r,   re   r,   r,   r-   r`   e  s    	zModelBeforeValidator.__call__NrŒ   r,   r,   r,   r-   r–   b  s   r–   z|Callable[[_AnyModelWrapValidator[_ModelType]], _decorators.PydanticDescriptorProxy[_decorators.ModelValidatorDecoratorInfo]])rv   r#   c                 C  s   d S rM   r,   ©rv   r,   r,   r-   Úmodel_validator€  s    r˜   zLiteral['before']zrCallable[[_AnyModelBeforeValidator], _decorators.PydanticDescriptorProxy[_decorators.ModelValidatorDecoratorInfo]]c                 C  s   d S rM   r,   r—   r,   r,   r-   r˜   ‰  s    z}Callable[[_AnyModelAfterValidator[_ModelType]], _decorators.PydanticDescriptorProxy[_decorators.ModelValidatorDecoratorInfo]]c                 C  s   d S rM   r,   r—   r,   r,   r-   r˜   ’  s    z$Literal[('wrap', 'before', 'after')]c                   s   dddœ‡ fdd„}|S )a'  Usage docs: https://docs.pydantic.dev/2.10/concepts/validators/#model-validators

    Decorate model methods for validation purposes.

    Example usage:
    ```python
    from typing_extensions import Self

    from pydantic import BaseModel, ValidationError, model_validator

    class Square(BaseModel):
        width: float
        height: float

        @model_validator(mode='after')
        def verify_square(self) -> Self:
            if self.width != self.height:
                raise ValueError('width and height do not match')
            return self

    s = Square(width=1, height=1)
    print(repr(s))
    #> Square(width=1.0, height=1.0)

    try:
        Square(width=1, height=2)
    except ValidationError as e:
        print(e)
        '''
        1 validation error for Square
          Value error, width and height do not match [type=value_error, input_value={'width': 1, 'height': 2}, input_type=dict]
        '''
    ```

    For more in depth examples, see [Model Validators](../concepts/validators.md#model-validators).

    Args:
        mode: A required string literal that specifies the validation mode.
            It can be one of the following: 'wrap', 'before', or 'after'.

    Returns:
        A decorator that can be used to decorate a function to be used as a model validator.
    r   r~   r   c                   s"   t  | ¡} t jˆ d�}t  | |¡S )Nr—   )r   r�   ZModelValidatorDecoratorInfor‚   rƒ   r—   r,   r-   r…   Ë  s    
zmodel_validator.<locals>.decr,   )rv   r…   r,   r—   r-   r˜   ›  s    0ÚAnyTypec                   @  s@   e Zd ZdZedddœdd„ƒZedddd	œd
d„ƒZejZdS )Ú
InstanceOfuž  Generic type for annotating a type that is an instance of a given class.

        Example:
            ```python
            from pydantic import BaseModel, InstanceOf

            class Foo:
                ...

            class Bar(BaseModel):
                foo: InstanceOf[Foo]

            Bar(foo=Foo())
            try:
                Bar(foo=42)
            except ValidationError as e:
                print(e)
                """
                [
                â”‚   {
                â”‚   â”‚   'type': 'is_instance_of',
                â”‚   â”‚   'loc': ('foo',),
                â”‚   â”‚   'msg': 'Input should be an instance of Foo',
                â”‚   â”‚   'input': 42,
                â”‚   â”‚   'ctx': {'class': 'Foo'},
                â”‚   â”‚   'url': 'https://errors.pydantic.dev/0.38.0/v/is_instance_of'
                â”‚   }
                ]
                """
            ```
        r™   ©Úitemr#   c                 C  s   t || ƒ f S rM   )r   ©r4   rœ   r,   r,   r-   Ú__class_getitem__ÿ  s    zInstanceOf.__class_getitem__r   r   r   ©Úsourcer"   r#   c                 C  sn   ddl m} t t |¡p|¡}z||ƒ}W n |k
rD   | Y S X tjdd„ |d�|d< tj||d�S d S )Nr   rJ   c                 S  s   || ƒS rM   r,   rN   r,   r,   r-   rQ     rR   z9InstanceOf.__get_pydantic_core_schema__.<locals>.<lambda>©rS   r%   rL   )Zpython_schemaZjson_schema)rU   rK   r   Zis_instance_schemar   Ú
get_originrW   Zjson_or_python_schema)r4   r    r"   rK   Zinstance_of_schemaÚoriginal_schemar,   r,   r-   r.     s    
 ÿ
z'InstanceOf.__get_pydantic_core_schema__N)	r6   r7   r8   r9   r;   rž   r.   ÚobjectÚ__hash__r,   r,   r,   r-   rš   Ý  s    rš   c                   @  s<   e Zd ZdZdddœdd„Zeddddœd	d
„ƒZejZdS )ÚSkipValidationa¬  If this is applied as an annotation (e.g., via `x: Annotated[int, SkipValidation]`), validation will be
            skipped. You can also use `SkipValidation[int]` as a shorthand for `Annotated[int, SkipValidation]`.

        This can be useful if you want to use a type annotation for documentation/IDE/type-checking purposes,
        and know that it is safe to skip validation for one or more of the fields.

        Because this converts the validation schema to `any_schema`, subsequent annotation-applied transformations
        may not have the expected effects. Therefore, when used, this annotation should generally be the final
        annotation applied to a type.
        r   r›   c                 C  s   t |tƒ f S rM   )r   r¦   r�   r,   r,   r-   rž   +  s    z SkipValidation.__class_getitem__r   r   rŸ   c                   s6   ||ƒ‰ d‡ fdd„gi}t j|t jdd„ ˆ d�d�S )NZ pydantic_js_annotation_functionsc                   s   |ˆ ƒS rM   r,   )Z_crP   ©r£   r,   r-   rQ   1  rR   z=SkipValidation.__get_pydantic_core_schema__.<locals>.<lambda>c                 S  s   || ƒS rM   r,   rN   r,   r,   r-   rQ   5  rR   r¡   )ÚmetadatarL   )r   Z
any_schemarW   )r4   r    r"   r¨   r,   r§   r-   r.   .  s     ÿþz+SkipValidation.__get_pydantic_core_schema__N)	r6   r7   r8   r9   rž   r;   r.   r¤   r¥   r,   r,   r,   r-   r¦     s
   
r¦   )Sr9   Ú
__future__r   Z_annotationsZdataclassesÚsysÚ	functoolsr   Útypesr   Útypingr   r   r   r   r	   r
   r   Zpydantic_corer   r   Z_core_schemaZtyping_extensionsr   r   r   r   Ú	_internalr   r   r   Zannotated_handlersr   Úerrorsr   Úversion_infor   Zinspect_validatorr'   Z	dataclassZ
slots_truer   r<   rI   rX   r\   rb   rf   rj   r(   r)   Z_V2ValidatorrZ   r[   Z_V2WrapValidatorr;   Ústaticmethodrm   r:   rn   rp   rq   rx   r‡   rˆ   ZValidatorFunctionWrapHandlerrŠ   r�   r�   r‘   r“   r”   r–   ZModelAfterValidatorWithoutInfoZValidationInfoZModelAfterValidatorZ_AnyModelWrapValidatorZ_AnyModelBeforeValidatorZ_AnyModelAfterValidatorr˜   r™   rš   r¦   r,   r,   r,   r-   Ú<module>   sÄ   $
;BaK
ýÿýÿ,
þú
ú
ûún
ÿ9<