
    Ki{                    J   U d Z ddlmZ ddlZddlZddlZddlmZ ddl	m
Z
mZ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mZ dd	lmZmZmZ dd
lmZ ddlm Z  ddl!m"Z" ddlm#Z#m$Z$ ejJ                  dk  rddlm&Z& nddl	m&Z& ejN                  Z( ejR                  dOddiejT                   G d d             Z+ ejR                  dOddiejT                   G d d             Z, ejR                  dOddiejT                   G d d             Z- ejR                  dOddiejT                   G d d             Z.e
r G d de&      Z/ G d de&      Z0 G d de&      Z1 G d  d!e&      Z2ee0ejf                  e/ejh                  f   Z5ee2ejl                  e1ejn                  f   Z8ee9eeef   e:eef   ee   f   Z;d"e<d#<    ed$ee5e;f   %      Z= ed&ee8e;f   %      Z>ed'   Z?d"e<d(<   ed)d)d*	 	 	 	 	 	 	 	 	 	 	 dPd+       Z@ed)d)d*	 	 	 	 	 	 	 	 	 	 	 dQd,       Z@ed)d)d-	 	 	 	 	 	 	 	 	 dRd.       Z@d/ded0	 	 	 	 	 	 	 	 	 	 	 dSd1Z@ ed2      ZA ed3d4      ZB G d5 d6ej                  e&eB         ZD G d7 d8e&eA         ZE G d9 d:e&eA         ZF G d; d<e&      ZG G d= d>e&      ZH G d? d@e&      ZI G dA dBe&      ZJeeAgeAf   ZK	 eeAej                  e   geAf   ZM	 eeFeA   eEeA   f   ZNeeIeJeGeHf   ZOeeMeA   eKeA   f   ZPe	 	 	 	 dTdC       ZQe	 	 	 	 dUdD       ZQe	 	 	 	 dVdE       ZQ	 	 	 	 dWdFZQ edG      ZRe
reeRd)f   ZSn) ejR                  dOi ejT                   G dH dI             ZSe
reeRd)f   ZTn) ejR                  dOi ejT                   G dJ dK             ZT edL      ZU G dM dN      ZVy)XzBThis module contains related classes and functions for validation.    )annotationsN)partialmethod)	TYPE_CHECKING	AnnotatedAnyCallableLiteralTypeVarUnioncastoverload)PydanticUndefinedcore_schema)Self	TypeAlias   )_decorators	_generics_internal_dataclass)GetCoreSchemaHandler)PydanticUserError)version_short)ArbitraryTypeWarningPydanticDeprecatedSince212)      )ProtocolfrozenTc                  6    e Zd ZU dZded<   ddZedd       Zy)	AfterValidatoraT  !!! abstract "Usage Documentation"
        [field *after* validators](../concepts/validators.md#field-after-validator)

    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 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funcc                2    ||      }t        | j                  dd      }|r;t        t        j                  | j                        }t        j
                  ||      S t        t        j                  | j                        }t        j                  ||      S )Nafterfieldmodetypeschema)_inspect_validatorr"   r   r   WithInfoValidatorFunction"with_info_after_validator_functionNoInfoValidatorFunction no_info_after_validator_function)selfsource_typehandlerr*   info_argr"   s         j/home/jay/workspace/scripts/.codegraph-venv/lib/python3.12/site-packages/pydantic/functional_validators.py__get_pydantic_core_schema__z+AfterValidator.__get_pydantic_core_schema__J   ss    %%diigGL==tyyIDAA$vVV;;TYYGD??VTT    c                (     | |j                         S )Nr"   r8   cls	decorators     r4   _from_decoratorzAfterValidator._from_decoratorT   s    	''r6   Nr1   r   r2   r   returncore_schema.CoreSchemar;   z>_decorators.Decorator[_decorators.FieldValidatorDecoratorInfo]r>   r   )__name__
__module____qualname____doc____annotations__r5   classmethodr<    r6   r4   r    r       s+    (T VUU ( (r6   r    c                  D    e Zd ZU dZded<   eZded<   d	dZed
d       Z	y)BeforeValidatora  !!! abstract "Usage Documentation"
        [field *before* validators](../concepts/validators.md#field-before-validator)

    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 used to generate the appropriate
            JSON Schema (in validation mode). The actual input type is `Any`.

    Example:
        ```python
        from typing 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_typec                    ||      }| j                   t        u rd n|j                  | j                         }t        | j                  dd      }|r<t        t        j                  | j                        }t        j                  |||      S t        t        j                  | j                        }t        j                  |||      S )Nbeforer%   r&   r*   json_schema_input_schema)rJ   r   generate_schemar+   r"   r   r   r,   #with_info_before_validator_functionr.   !no_info_before_validator_functionr0   r1   r2   r*   input_schemar3   r"   s          r4   r5   z,BeforeValidator.__get_pydantic_core_schema__~   s    % **.?? (()D)DE 	 &diihWM==tyyIDBB)5  ;;TYYGD@@Vl r6   c                R     | |j                   |j                  j                        S N)r"   rJ   r"   inforJ   r9   s     r4   r<   zBeforeValidator._from_decorator   #    #,>>#H#H
 	
r6   Nr=   r@   
rA   rB   rC   rD   rE   r   rJ   r5   rF   r<   rG   r6   r4   rI   rI   Y   s5    @ VU"3C3, 
 
r6   rI   c                  D    e Zd ZU dZded<   eZded<   d	dZed
d       Z	y)PlainValidatora  !!! abstract "Usage Documentation"
        [field *plain* validators](../concepts/validators.md#field-plain-validator)

    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 used to generate the appropriate
            JSON Schema (in validation mode). The actual input type is `Any`.

    Example:
        ```python
        from typing import Annotated, Union

        from pydantic import BaseModel, PlainValidator

        def validate(v: object) -> int:
            if not isinstance(v, (int, str)):
                raise ValueError(f'Expected int or str, got {type(v)}')

            return int(v) + 1

        MyInt = Annotated[
            int,
            PlainValidator(validate, 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   rJ   c           
        ddl m} 	  ||      }|j                  dt        j                  d ||j                  |                  }|j                  | j                        }t        | j                  dd      }|r<t        t        j                  | j                        }t        j                  |||	      S t        t        j                  | j                        }t        j                  |||	      S # |$ r d }Y w xY w)
Nr   )PydanticSchemaGenerationErrorserializationc                     ||       S NrG   vhs     r4   <lambda>z=PlainValidator.__get_pydantic_core_schema__.<locals>.<lambda>   
    !A$ r6   )functionr*   return_schemaplainr%   r&   )r^   rN   )pydanticr]   getr   #wrap_serializer_function_ser_schemarO   rJ   r+   r"   r   r,   "with_info_plain_validator_functionr.    no_info_plain_validator_function)	r0   r1   r2   r]   r*   r^   rS   r3   r"   s	            r4   r5   z+PlainValidator.__get_pydantic_core_schema__   s     	;	![)F #JJ??.!")"9"9+"FM ..t/J/JK%diigGL==tyyIDAA+)5  ;;TYYGD??+)5  - 	! M	!s   A C5 5C?>C?c                R     | |j                   |j                  j                        S rU   rV   r9   s     r4   r<   zPlainValidator._from_decorator   rX   r6   Nr=   r@   )
rA   rB   rC   rD   rE   r   rJ   r5   rF   r<   rG   r6   r4   r[   r[      s6    ,\ VU"%C%'R 
 
r6   r[   c                  D    e Zd ZU dZded<   eZded<   d	dZed
d       Z	y)WrapValidatora  !!! abstract "Usage Documentation"
        [field *wrap* validators](../concepts/validators.md#field-wrap-validator)

    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 used to generate the appropriate
            JSON Schema (in validation mode). The actual input type is `Any`.

    ```python
    from datetime import datetime
    from typing 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   rJ   c                    ||      }| j                   t        u rd n|j                  | j                         }t        | j                  dd      }|r<t        t        j                  | j                        }t        j                  |||      S t        t        j                  | j                        }t        j                  |||      S )Nwrapr%   r&   rM   )rJ   r   rO   r+   r"   r   r   WithInfoWrapValidatorFunction!with_info_wrap_validator_functionNoInfoWrapValidatorFunctionno_info_wrap_validator_functionrR   s          r4   r5   z*WrapValidator.__get_pydantic_core_schema__+  s    % **.?? (()D)DE 	 &diif7KAA499MD@@)5  ??KD>>)5 r6   c                R     | |j                   |j                  j                        S rU   rV   r9   s     r4   r<   zWrapValidator._from_decoratorC  rX   r6   Nr=   r@   rY   rG   r6   r4   rp   rp      s5    $L ^]"3C30 
 
r6   rp   c                      e Zd ZddZy)_OnlyValueValidatorClsMethodc                    y r`   rG   r0   r:   values      r4   __call__z%_OnlyValueValidatorClsMethod.__call__N      r6   Nr:   r   r|   r   r>   r   rA   rB   rC   r}   rG   r6   r4   ry   ry   M  s    ?r6   ry   c                      e Zd ZddZy)_V2ValidatorClsMethodc                    y r`   rG   r0   r:   r|   rW   s       r4   r}   z_V2ValidatorClsMethod.__call__Q  r~   r6   Nr:   r   r|   r   rW   core_schema.ValidationInfo[Any]r>   r   r   rG   r6   r4   r   r   P  s    fr6   r   c                      e Zd ZddZy) _OnlyValueWrapValidatorClsMethodc                    y r`   rG   r0   r:   r|   r2   s       r4   r}   z)_OnlyValueWrapValidatorClsMethod.__call__T  r~   r6   N)r:   r   r|   r   r2   (core_schema.ValidatorFunctionWrapHandlerr>   r   r   rG   r6   r4   r   r   S  s    rr6   r   c                  (    e Zd Z	 	 	 	 	 	 	 	 	 	 ddZy)_V2WrapValidatorClsMethodc                    y r`   rG   r0   r:   r|   r2   rW   s        r4   r}   z"_V2WrapValidatorClsMethod.__call__W  s     r6   N)
r:   r   r|   r   r2   r   rW   r   r>   r   r   rG   r6   r4   r   r   V  s7    		 	 >		
 2	 	r6   r   r   _PartialClsOrStaticMethod"_V2BeforeAfterOrPlainValidatorType)bound_V2WrapValidatorType)rL   r$   rr   rh   FieldValidatorModes.)check_fieldsrJ   c                   y r`   rG   r%   r'   r   rJ   fieldss        r4   field_validatorr   y  s     >Ar6   c                   y r`   rG   r   s        r4   r   r     s	     Z]r6   )r'   r   c                   y r`   rG   )r%   r'   r   r   s       r4   r   r     s	     Z]r6   r$   )r'   r   rJ   c                  t        |       st        | t              rt        dd      dvrt        urt        dd      t        u rdk(  rt
        | gt        d D              st        d	d
      	 	 	 	 dfd}|S )a  !!! abstract "Usage Documentation"
        [field validators](../concepts/validators.md#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:
        *fields: The field names the validator should apply to.
        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'`.

    Raises:
        PydanticUserError:
            - If the decorator is used without any arguments (at least one field name must be provided).
            - If the provided field names are not strings.
            - If `json_schema_input_type` is provided with an unsupported `mode`.
            - If the decorator is applied to an instance method.
    zThe `@field_validator` decorator cannot be used without arguments, at least one field must be provided. For example: `@field_validator('<field_name>', ...)`.zdecorator-missing-argumentscode)rL   rh   rr   z;`json_schema_input_type` can't be used when mode is set to zvalidator-input-typerh   c              3  <   K   | ]  }t        |t                y wr`   )
isinstancestr).0r%   s     r4   	<genexpr>z"field_validator.<locals>.<genexpr>  s     :%z%%:s   zThe provided field names to the `@field_validator` decorator should be strings. For example: `@field_validator('<field_name_1>', '<field_name_2>', ...).`zdecorator-invalid-fieldsc                    t        j                  |       rt        dd      t        j                  |       } t        j                        }t        j
                  | |      S )NzFThe `@field_validator` decorator cannot be applied to instance methodszvalidator-instance-methodr   )r   r'   r   rJ   )r   is_instance_method_from_sigr   %ensure_classmethod_based_on_signatureFieldValidatorDecoratorInfoPydanticDescriptorProxy)fdec_infor   r   rJ   r'   s     r4   deczfield_validator.<locals>.dec  sg     2215#X0  ==a@::<Xn
 221h??r6   )r   zHCallable[..., Any] | staticmethod[Any, Any] | classmethod[Any, Any, Any]r>   (_decorators.PydanticDescriptorProxy[Any])callabler   rF   r   r   r   all)r%   r'   r   rJ   r   r   s    ```` r4   r   r     s    @ *UK8D.
 	
 ..3IQb3bI$R'
 	

 !22tw!$^V^F:6::X+
 	
@S@	1@ @" Jr6   
_ModelType_ModelTypeCo)	covariantc                  &    e Zd ZdZ	 d	 	 	 	 	 ddZy)ModelWrapValidatorHandlerz]`@model_validator` decorated function handler argument type. This is used when `mode='wrap'`.Nc                    y r`   rG   )r0   r|   outer_locations      r4   r}   z"ModelWrapValidatorHandler.__call__  s     	r6   r`   )r|   r   r   zstr | int | Noner>   r   rA   rB   rC   rD   r}   rG   r6   r4   r   r   	  s+    g
 ,0 )
 
r6   r   c                  (    e Zd ZdZ	 	 	 	 	 	 	 	 ddZy)ModelWrapValidatorWithoutInfozA `@model_validator` decorated function signature.
    This is used when `mode='wrap'` and the function does not have info argument.
    c                    y r`   rG   r   s       r4   r}   z&ModelWrapValidatorWithoutInfo.__call__  s     r6   N)r:   type[_ModelType]r|   r   r2   %ModelWrapValidatorHandler[_ModelType]r>   r   r   rG   r6   r4   r   r     s2    		 	 7	 
	r6   r   c                  ,    e Zd ZdZ	 	 	 	 	 	 	 	 	 	 ddZy)ModelWrapValidatorzSA `@model_validator` decorated function signature. This is used when `mode='wrap'`.c                    y r`   rG   r   s        r4   r}   zModelWrapValidator.__call__)  s     r6   N)
r:   r   r|   r   r2   r   rW   zcore_schema.ValidationInfor>   r   r   rG   r6   r4   r   r   &  s:    ]

 
 7
 )
 

r6   r   c                       e Zd ZdZ	 	 	 	 ddZy)#FreeModelBeforeValidatorWithoutInfoA `@model_validator` decorated function signature.
    This is used when `mode='before'` and the function does not have info argument.
    c                    y r`   rG   )r0   r|   s     r4   r}   z,FreeModelBeforeValidatorWithoutInfo.__call__;  s     r6   N)r|   r   r>   r   r   rG   r6   r4   r   r   6  s     
  
r6   r   c                  $    e Zd ZdZ	 	 	 	 	 	 ddZy)ModelBeforeValidatorWithoutInfor   c                    y r`   rG   r{   s      r4   r}   z(ModelBeforeValidatorWithoutInfo.__call__J       r6   Nr   r   rG   r6   r4   r   r   E  s(      
r6   r   c                  $    e Zd ZdZ	 	 	 	 	 	 ddZy)FreeModelBeforeValidatorUA `@model_validator` decorated function signature. This is used when `mode='before'`.c                    y r`   rG   )r0   r|   rW   s      r4   r}   z!FreeModelBeforeValidator.__call__X  r   r6   N)r|   r   rW   r   r>   r   r   rG   r6   r4   r   r   U  s(    _
  . 
r6   r   c                  (    e Zd ZdZ	 	 	 	 	 	 	 	 ddZy)ModelBeforeValidatorr   c                    y r`   rG   r   s       r4   r}   zModelBeforeValidator.__call__f  s     r6   Nr   r   rG   r6   r4   r   r   c  s0    _		 	 .	 
	r6   r   c                     y r`   rG   r'   s    r4   model_validatorr          r6   c                     y r`   rG   r   s    r4   r   r     r   r6   c                     y r`   rG   r   s    r4   r   r     r   r6   c                     d fd}|S )a@  !!! abstract "Usage Documentation"
        [Model Validators](../concepts/validators.md#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.
    c                    t        j                  |       } dk(  r8t        | t              r(t	        j
                  t        dt                dd       t        j                        }t        j                  | |      S )Nr$   zUsing `@model_validator` with mode='after' on a classmethod is deprecated. Instead, use an instance method. See the documentation at https://docs.pydantic.dev/z,/concepts/validators/#model-after-validator.   )categorymessage
stacklevelr   )
r   r   r   rF   warningswarnr   r   ModelValidatorDecoratorInfor   )r   r   r'   s     r4   r   zmodel_validator.<locals>.dec  sw    ==a@7?z![9MM3JJW/IZ  [GH  ::E221h??r6   )r   r   r>   r   rG   )r'   r   s   ` r4   r   r     s    b@  Jr6   AnyTypec                  L    e Zd ZdZedd       Zedd       Zej                  Zy)
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'
                │   }
                ]
                """
            ```
        c                "    t         | |        f   S r`   )r   r:   items     r4   __class_getitem__zInstanceOf.__class_getitem__  s    T35[))r6   c                    ddl m} t        j                  t	        j
                  |      xs |      }	  ||      }t        j                  d |      |d<   t        j                  ||      S # |$ r |cY S w xY w)Nr   )GENERATE_SCHEMA_ERRORSc                     ||       S r`   rG   ra   s     r4   rd   z9InstanceOf.__get_pydantic_core_schema__.<locals>.<lambda>  re   r6   rf   r*   r^   )python_schemajson_schema)#pydantic._internal._generate_schemar   r   is_instance_schemar   
get_originrk   json_or_python_schema)r:   sourcer2   r   instance_of_schemaoriginal_schemas         r4   r5   z'InstanceOf.__get_pydantic_core_schema__  s    R "-!?!?	@T@TU[@\@f`f!gx")&/ 7B6e6e.7"?3 #88GYgvww * *))*s   A. .A87A8N)r   r   r>   r   r   r   r2   r   r>   r?   )	rA   rB   rC   rD   rF   r   r5   object__hash__rG   r6   r4   r   r     s=    	@ 
	* 
	* 
	x 
	x& ??r6   r   c                  B    e Zd ZdZddZedd       Zej                  Zy)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.
        c                (    t         |t               f   S r`   )r   r   r   s     r4   r   z SkipValidation.__class_getitem__7  s    T>#3344r6   c                   t        j                         5  t        j                  dt                ||      d d d        dfdgi}t	        j
                  |t	        j                  d             S # 1 sw Y   >xY w)Nignore pydantic_js_annotation_functionsc                     |      S r`   rG   )_crc   r   s     r4   rd   z=SkipValidation.__get_pydantic_core_schema__.<locals>.<lambda>?  s    1_K] r6   c                     ||       S r`   rG   ra   s     r4   rd   z=SkipValidation.__get_pydantic_core_schema__.<locals>.<lambda>C  re   r6   r   )metadatar^   )r   catch_warningssimplefilterr   r   
any_schemark   )r:   r   r2   r   r   s       @r4   r5   z+SkipValidation.__get_pydantic_core_schema__:  sw    ((* 2%%h0DE")&/2 ;=]<^_H))!)MM. 	2 2s   #A66A?N)r   r   r>   r   r   )	rA   rB   rC   rD   r   rF   r5   r   r   rG   r6   r4   r   r   *  s+    			5 

	 

	 ??r6   r   
_FromTypeTc                       e Zd ZdZddZddZy)
ValidateAsa  A helper class to validate a custom type from a type that is natively supported by Pydantic.

    Args:
        from_type: The type natively supported by Pydantic to use to perform validation.
        instantiation_hook: A callable taking the validated type as an argument, and returning
            the populated custom type.

    Example:
        ```python {lint="skip"}
        from typing import Annotated

        from pydantic import BaseModel, TypeAdapter, ValidateAs

        class MyCls:
            def __init__(self, a: int) -> None:
                self.a = a

            def __repr__(self) -> str:
                return f"MyCls(a={self.a})"

        class Model(BaseModel):
            a: int


        ta = TypeAdapter(
            Annotated[MyCls, ValidateAs(Model, lambda v: MyCls(a=v.a))]
        )

        print(ta.validate_python({'a': 1}))
        #> MyCls(a=1)
        ```
    c                    || _         || _        y r`   )	from_typeinstantiation_hook)r0   r  r  s      r4   __init__zValidateAs.__init__p  s    ""4r6   c                h     || j                         }t        j                  | j                  |      S )Nr)   )r  r   r/   r  )r0   r   r2   r*   s       r4   r5   z'ValidateAs.__get_pydantic_core_schema__t  s/    (;;##
 	
r6   N)r  zCallable[[_FromTypeT], Any]r  ztype[_FromTypeT]r>   Noner   )rA   rB   rC   rD   r  r5   rG   r6   r4   r  r  M  s    D5
r6   r  rG   )r%   r   r   r   r'   Literal['wrap']r   bool | NonerJ   r   r>   z6Callable[[_V2WrapValidatorType], _V2WrapValidatorType])r%   r   r   r   r'   zLiteral['before', 'plain']r   r  rJ   r   r>   RCallable[[_V2BeforeAfterOrPlainValidatorType], _V2BeforeAfterOrPlainValidatorType])
r%   r   r   r   r'   Literal['after']r   r  r>   r  )r%   r   r   r   r'   r   r   r  rJ   r   r>   zCallable[[Any], Any])r'   r
  r>   z|Callable[[_AnyModelWrapValidator[_ModelType]], _decorators.PydanticDescriptorProxy[_decorators.ModelValidatorDecoratorInfo]])r'   zLiteral['before']r>   zrCallable[[_AnyModelBeforeValidator], _decorators.PydanticDescriptorProxy[_decorators.ModelValidatorDecoratorInfo]])r'   r  r>   z}Callable[[_AnyModelAfterValidator[_ModelType]], _decorators.PydanticDescriptorProxy[_decorators.ModelValidatorDecoratorInfo]])r'   z"Literal['wrap', 'before', 'after']r>   r   )WrD   
__future__r   _annotationsdataclassessysr   	functoolsr   typingr   r   r   r   r	   r
   r   r   r   pydantic_corer   r   typing_extensionsr   r   	_internalr   r   r   annotated_handlersr   errorsr   versionr   r   r   version_infor   inspect_validatorr+   	dataclass
slots_truer    rI   r[   rp   ry   r   r   r   r,   r.   _V2Validatorrs   ru   _V2WrapValidatorrF   staticmethodr   rE   r   r   r   r   r   r   ValidatorFunctionWrapHandlerr   r   r   r   r   r   r   ModelAfterValidatorWithoutInfoValidationInfoModelAfterValidator_AnyModelWrapValidator_AnyModelBeforeValidator_AnyModelAfterValidatorr   r   r   r   r  r  rG   r6   r4   <module>r(     s   H 2  
  # c c c 8 - B B 4 % " Fg* 22  EdE&9&D&DE9( 9( F9(x EdE&9&D&DE?
 ?
 F?
D EdE&9&D&DE`
 `
 F`
F EdE&9&D&DEG
 G
 FG
T @x @g gs8 sH  --$++	-L !11(//	1 ,1S#s]1K\Z]_bZbMcersvew1w+xyx)0,L";;<*& ##9GWYrGrAst!()K!L Y L 
 !$"%AA A 	A
 A  A <A 
A 
 !$"%]] ] %	]
 ]  ] X] 
] 

 ! #]] ] 	]
 ] X] 
] !( $"3ii i 	i
 i  i iX \"
~6	 H H(S_J` 	HZ$8 "*-  ( h  x 8  "*:,
*B!C  
K,F,Fs,KLjXY  Z1*=?\]g?hhi  24WYxx    3J ?A_`jAk kl  

 
 

 
 

 
A
,A 	AH )
 7C<(J [<0;;<9# 9# =9#x w|,N [<0;;<# # =#> \"
,
 ,
r6   