U
    Qh                    @  s
	  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	mZ ddl
mZ ddlm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mZmZmZmZmZmZm Z m!Z!m"Z"m#Z# dd
l$m%Z% ddl&Z&ddl&m'Z'm(Z(m)Z) ddl*m+Z+m,Z,m-Z-m.Z. ddl/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5 ddl6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z< ddl=m>Z> ddl?m@Z@mAZA ddlBmCZC ddlDmEZE ddlFmGZG dZHedZIejJG dd de8jKe'ZLe0eMeL f ZNdddddddddddddddddZOe0ePe&Qdf ZRe0ePe&Sdf ZTe0ePe&Udf ZVe0ePe&Wdf ZXe0ePeL f ZYejJG d d! d!e8jKZZdddddddd"dd#d#d#d#d#dd$d%d&d'Z[e0e\e&Qdf Z]e0e\e&Sdf Z^e0e\e&Udf Z_e0e\e&Wdf Z`e0e\eLd(f Zae0e\eZd)f Zbdddd*dddd+d,d-d.Zce0edeL f ZeejJd(d/G d0d1 d1e&jfZgdddddddd2ddddddd3d4d5d6d7Zhe0eieL f Zjed8ed9Zkddd:d;ddd<d=d>d?Zlddd:d;ddd@d=dAdBZmedCZnddddDdEddddFdGdHdIZoedJZpere0epdKf ZqnG dLdM dMZqddddddddddN	ddOdOdOdOdOddddPdQ
dRdSZrejJf e9jsG dTdU dUZte0e%etdf Zue0e%etdVf Zve0e%etdWf Zwe0e%etdXf ZxejJG dYdZ dZZye0eeyd[f Zze0eeyd\f Z{e0eeyd]f Z|e0eeyd^f Z}ere0epdKf Z~nG d_d` d`Z~edaZG dbdc dcee ZdddedfdgdhdiZG djdk dkee ZdadldmdndoZdpdedqdgdrdsZG dtdu duee ZG dvdw dweei ZG dxdy dyeed ZG dzd{ d{eieZe5d|eGd}G d~d deiZG dd dePZdldldlddddZere0e	dKf Ze0e	dKf ZnG dd dZG dd dZdddddddddddddddZere0edKf Ze0edKf Ze0edKf Ze0edKf Zn8G dd dZG dd dZG dd dZG dd dZG dd de2ZG dd deZG dd deZejJf e9jsG dd dZejJf e9jsG dd dZe0edeedf Ze0eieedf Ze0edeedf Ze0eieedf Ze>eZejJf e9jsG dd dZejJf e9jsdd(iG dd dZejJf e9jsdd(iG dd dZePe\eieMeeedhZddldddZG dd dZerBe ed eeidf eieMePe\df Zded< ne4de0e e0ed edf e0eeidf edf e0eiedlf e0eMedf e0ePedf e0e\edf e0dedf f eedddef ZG dd dZe0eIef ZejJG dd de8jKe'ZdS )z8The types module contains custom types used by pydantic.    )annotationsN)datedatetime)Decimal)Enum)Path)
ModuleType)TYPE_CHECKINGAnyCallableClassVarDict	FrozenSetGenericHashableIteratorListPatternSetTypeVarUnioncastget_args
get_origin)UUID)BaseMetadataMaxLenMinLen)
CoreSchemaPydanticCustomErrorSchemaSerializercore_schema)	AnnotatedLiteralProtocol	TypeAliasTypeAliasType
deprecated   )_core_utils_fields_internal_dataclass_typing_extra_utils_validators)getattr_migration)GetCoreSchemaHandlerGetJsonSchemaHandlerPydanticUserError)JsonSchemaValue)PydanticDeprecatedSince20)=Strict	StrictStr
SocketPathconbytesconlistconsetconfrozensetconstrImportStringconintPositiveIntNegativeIntNonNegativeIntNonPositiveIntconfloatPositiveFloatNegativeFloatNonNegativeFloatNonPositiveFloatFiniteFloat
condecimalUUID1UUID3UUID4UUID5FilePathDirectoryPathNewPathJsonSecret	SecretStrSecretBytes
StrictBoolStrictBytes	StrictIntStrictFloatPaymentCardNumberByteSizePastDate
FutureDatePastDatetimeFutureDatetimecondateAwareDatetimeNaiveDatetimeAllowInfNanEncoderProtocolEncodedBytes
EncodedStrBase64EncoderBase64Bytes	Base64StrBase64UrlBytesBase64UrlStrGetPydanticSchemaStringConstraintsTagDiscriminator	JsonValueOnErrorOmitFailFastTc                   @  s,   e Zd ZU dZdZded< ddddZd	S )
r6   aL  Usage docs: https://docs.pydantic.dev/2.10/concepts/strict_mode/#strict-mode-with-annotated-strict

    A field metadata class to indicate that a field should be validated in strict mode.
    Use this class as an annotation via [`Annotated`](https://docs.python.org/3/library/typing.html#typing.Annotated), as seen below.

    Attributes:
        strict: Whether to validate the field in strict mode.

    Example:
        ```python
        from typing_extensions import Annotated

        from pydantic.types import Strict

        StrictBool = Annotated[bool, Strict()]
        ```
    Tboolstrictintreturnc                 C  s
   t | jS N)hashru   self r}   4./venv/lib/python3.8/site-packages/pydantic/types.py__hash__   s    zStrict.__hash__N)__name__
__module____qualname____doc__ru   __annotations__r   r}   r}   r}   r~   r6   r   s   
r6   ru   gtgeltlemultiple_ofbool | None
int | Nonez	type[int])ru   r   r   r   r   r   rx   c              	   C  s@   t t| dk	rt| ndtj||||d|dk	r8t|ndf S )a<  
    !!! warning "Discouraged"
        This function is **discouraged** in favor of using
        [`Annotated`](https://docs.python.org/3/library/typing.html#typing.Annotated) with
        [`Field`][pydantic.fields.Field] instead.

        This function will be **deprecated** in Pydantic 3.0.

        The reason is that `conint` returns a type, which doesn't play well with static analysis tools.

        === ":x: Don't do this"
            ```python
            from pydantic import BaseModel, conint

            class Foo(BaseModel):
                bar: conint(strict=True, gt=0)
            ```

        === ":white_check_mark: Do this"
            ```python
            from typing_extensions import Annotated

            from pydantic import BaseModel, Field

            class Foo(BaseModel):
                bar: Annotated[int, Field(strict=True, gt=0)]
            ```

    A wrapper around `int` that allows for additional constraints.

    Args:
        strict: Whether to validate the integer in strict mode. Defaults to `None`.
        gt: The value must be greater than this.
        ge: The value must be greater than or equal to this.
        lt: The value must be less than this.
        le: The value must be less than or equal to this.
        multiple_of: The value must be a multiple of this.

    Returns:
        The wrapped integer type.

    ```python
    from pydantic import BaseModel, ValidationError, conint

    class ConstrainedExample(BaseModel):
        constrained_int: conint(gt=1)

    m = ConstrainedExample(constrained_int=2)
    print(repr(m))
    #> ConstrainedExample(constrained_int=2)

    try:
        ConstrainedExample(constrained_int=0)
    except ValidationError as e:
        print(e.errors())
        '''
        [
            {
                'type': 'greater_than',
                'loc': ('constrained_int',),
                'msg': 'Input should be greater than 1',
                'input': 0,
                'ctx': {'gt': 1},
                'url': 'https://errors.pydantic.dev/2/v/greater_than',
            }
        ]
        '''
    ```

    Nr   r   r   r   )r"   rv   r6   annotated_typesInterval
MultipleOfr   r}   r}   r~   r?      s    Or?   c                   @  s,   e Zd ZU dZdZded< ddddZd	S )
rc   a  A field metadata class to indicate that a field should allow `-inf`, `inf`, and `nan`.

    Use this class as an annotation via [`Annotated`](https://docs.python.org/3/library/typing.html#typing.Annotated), as seen below.

    Attributes:
        allow_inf_nan: Whether to allow `-inf`, `inf`, and `nan`. Defaults to `True`.

    Example:
        ```python
        from typing_extensions import Annotated

        from pydantic.types import AllowInfNan

        LaxFloat = Annotated[float, AllowInfNan()]
    Trt   allow_inf_nanrv   rw   c                 C  s
   t | jS ry   )rz   r   r{   r}   r}   r~   r     s    zAllowInfNan.__hash__N)r   r   r   r   r   r   r   r}   r}   r}   r~   rc     s   
rc   ru   r   r   r   r   r   r   zfloat | Noneztype[float])ru   r   r   r   r   r   r   rx   c              	   C  sR   t t| dk	rt| ndtj||||d|dk	r8t|nd|dk	rJt|ndf S )a  
    !!! warning "Discouraged"
        This function is **discouraged** in favor of using
        [`Annotated`](https://docs.python.org/3/library/typing.html#typing.Annotated) with
        [`Field`][pydantic.fields.Field] instead.

        This function will be **deprecated** in Pydantic 3.0.

        The reason is that `confloat` returns a type, which doesn't play well with static analysis tools.

        === ":x: Don't do this"
            ```python
            from pydantic import BaseModel, confloat

            class Foo(BaseModel):
                bar: confloat(strict=True, gt=0)
            ```

        === ":white_check_mark: Do this"
            ```python
            from typing_extensions import Annotated

            from pydantic import BaseModel, Field

            class Foo(BaseModel):
                bar: Annotated[float, Field(strict=True, gt=0)]
            ```

    A wrapper around `float` that allows for additional constraints.

    Args:
        strict: Whether to validate the float in strict mode.
        gt: The value must be greater than this.
        ge: The value must be greater than or equal to this.
        lt: The value must be less than this.
        le: The value must be less than or equal to this.
        multiple_of: The value must be a multiple of this.
        allow_inf_nan: Whether to allow `-inf`, `inf`, and `nan`.

    Returns:
        The wrapped float type.

    ```python
    from pydantic import BaseModel, ValidationError, confloat

    class ConstrainedExample(BaseModel):
        constrained_float: confloat(gt=1.0)

    m = ConstrainedExample(constrained_float=1.1)
    print(repr(m))
    #> ConstrainedExample(constrained_float=1.1)

    try:
        ConstrainedExample(constrained_float=0.9)
    except ValidationError as e:
        print(e.errors())
        '''
        [
            {
                'type': 'greater_than',
                'loc': ('constrained_float',),
                'msg': 'Input should be greater than 1',
                'input': 0.9,
                'ctx': {'gt': 1.0},
                'url': 'https://errors.pydantic.dev/2/v/greater_than',
            }
        ]
        '''
    ```
    Nr   )r"   floatr6   r   r   r   rc   r   r}   r}   r~   rD     s    PrD   TF
min_length
max_lengthru   ztype[bytes])r   r   ru   rx   c                 C  s*   t t|dk	rt|ndt| p d|f S )a&  A wrapper around `bytes` that allows for additional constraints.

    Args:
        min_length: The minimum length of the bytes.
        max_length: The maximum length of the bytes.
        strict: Whether to validate the bytes in strict mode.

    Returns:
        The wrapped bytes type.
    Nr   )r"   bytesr6   r   Lenr   r}   r}   r~   r9     s    r9   )frozenc                   @  st   e Zd ZU dZdZded< dZded< dZded< dZded< dZ	ded	< dZ
ded
< dZded< ddddZdS )rm   a  Usage docs: https://docs.pydantic.dev/2.10/concepts/fields/#string-constraints

    A field metadata class to apply constraints to `str` types.
    Use this class as an annotation via [`Annotated`](https://docs.python.org/3/library/typing.html#typing.Annotated), as seen below.

    Attributes:
        strip_whitespace: Whether to remove leading and trailing whitespace.
        to_upper: Whether to convert the string to uppercase.
        to_lower: Whether to convert the string to lowercase.
        strict: Whether to validate the string in strict mode.
        min_length: The minimum length of the string.
        max_length: The maximum length of the string.
        pattern: A regex pattern that the string must match.

    Example:
        ```python
        from typing_extensions import Annotated

        from pydantic.types import StringConstraints

        ConstrainedStr = Annotated[str, StringConstraints(min_length=1, max_length=10)]
        ```
    Nr   strip_whitespaceto_upperto_lowerru   r   r   r   str | Pattern[str] | NonepatternzIterator[BaseMetadata]rw   c                 c  s   | j d k	rt| j V  | jd k	r,t| jV  | jd k	rBt| jV  | jd k	sj| jd k	sj| jd k	sj| j	d k	rt
j| j| j	| j| jdV  d S )N)r   r   r   r   )r   r   r   r   ru   r6   r   r   r   r   r*   pydantic_general_metadatar{   r}   r}   r~   __iter__  s(    


zStringConstraints.__iter__)r   r   r   r   r   r   r   r   ru   r   r   r   r   r}   r}   r}   r~   rm     s   
rm   r   r   r   ru   r   r   r   r   z	type[str])r   r   r   ru   r   r   r   rx   c                 C  s   t tt| ||||||df S )am  
    !!! warning "Discouraged"
        This function is **discouraged** in favor of using
        [`Annotated`](https://docs.python.org/3/library/typing.html#typing.Annotated) with
        [`StringConstraints`][pydantic.types.StringConstraints] instead.

        This function will be **deprecated** in Pydantic 3.0.

        The reason is that `constr` returns a type, which doesn't play well with static analysis tools.

        === ":x: Don't do this"
            ```python
            from pydantic import BaseModel, constr

            class Foo(BaseModel):
                bar: constr(strip_whitespace=True, to_upper=True, pattern=r'^[A-Z]+$')
            ```

        === ":white_check_mark: Do this"
            ```python
            from typing_extensions import Annotated

            from pydantic import BaseModel, StringConstraints

            class Foo(BaseModel):
                bar: Annotated[
                    str,
                    StringConstraints(
                        strip_whitespace=True, to_upper=True, pattern=r'^[A-Z]+$'
                    ),
                ]
            ```

    A wrapper around `str` that allows for additional constraints.

    ```python
    from pydantic import BaseModel, constr

    class Foo(BaseModel):
        bar: constr(strip_whitespace=True, to_upper=True)

    foo = Foo(bar='  hello  ')
    print(foo)
    #> bar='HELLO'
    ```

    Args:
        strip_whitespace: Whether to remove leading and trailing whitespace.
        to_upper: Whether to turn all characters to uppercase.
        to_lower: Whether to turn all characters to lowercase.
        strict: Whether to validate the string in strict mode.
        min_length: The minimum length of the string.
        max_length: The maximum length of the string.
        pattern: A regex pattern to validate the string against.

    Returns:
        The wrapped string type.
    r   )r"   strrm   r   r}   r}   r~   r=     s    Dr=   HashableItemType)Zbound)r   r   ztype[HashableItemType]ztype[set[HashableItemType]])	item_typer   r   rx   c                C  s   t t|  t|pd|f S )a  A wrapper around `typing.Set` that allows for additional constraints.

    Args:
        item_type: The type of the items in the set.
        min_length: The minimum length of the set.
        max_length: The maximum length of the set.

    Returns:
        The wrapped set type.
    r   )r"   r   r   r   r   r   r   r}   r}   r~   r;   B  s    r;   z!type[frozenset[HashableItemType]]c                C  s   t t|  t|pd|f S )a:  A wrapper around `typing.FrozenSet` that allows for additional constraints.

    Args:
        item_type: The type of the items in the frozenset.
        min_length: The minimum length of the frozenset.
        max_length: The maximum length of the frozenset.

    Returns:
        The wrapped frozenset type.
    r   )r"   r   r   r   r   r}   r}   r~   r<   R  s    r<   AnyItemType)r   r   unique_itemsztype[AnyItemType]ztype[list[AnyItemType]])r   r   r   r   rx   c                C  s0   |dk	rt dddtt|  t|p&d|f S )ab  A wrapper around typing.List that adds validation.

    Args:
        item_type: The type of the items in the list.
        min_length: The minimum length of the list. Defaults to None.
        max_length: The maximum length of the list. Defaults to None.
        unique_items: Whether the items in the list must be unique. Defaults to None.
            !!! warning Deprecated
                The `unique_items` parameter is deprecated, use `Set` instead.
                See [this issue](https://github.com/pydantic/pydantic-core/issues/296) for more details.

    Returns:
        The wrapped list type.
    Nz`unique_items` is removed, use `Set` instead(this feature is discussed in https://github.com/pydantic/pydantic-core/issues/296)zremoved-kwargscoder   )r3   r"   r   r   r   )r   r   r   r   r}   r}   r~   r:   e  s    r:   AnyType.c                   @  sr   e Zd ZdZedddddZedddd	d
dZeddddddZedddddZ	ddddZ
dS )r>   a  A type that can be used to import a Python object from a string.

        `ImportString` expects a string and loads the Python object importable at that dotted path.
        Attributes of modules may be separated from the module by `:` or `.`, e.g. if `'math:cos'` is provided,
        the resulting field value would be the function `cos`. If a `.` is used and both an attribute and submodule
        are present at the same path, the module will be preferred.

        On model instantiation, pointers will be evaluated and imported. There is
        some nuance to this behavior, demonstrated in the examples below.

        ```python
        import math

        from pydantic import BaseModel, Field, ImportString, ValidationError

        class ImportThings(BaseModel):
            obj: ImportString

        # A string value will cause an automatic import
        my_cos = ImportThings(obj='math.cos')

        # You can use the imported function as you would expect
        cos_of_0 = my_cos.obj(0)
        assert cos_of_0 == 1

        # A string whose value cannot be imported will raise an error
        try:
            ImportThings(obj='foo.bar')
        except ValidationError as e:
            print(e)
            '''
            1 validation error for ImportThings
            obj
              Invalid python path: No module named 'foo.bar' [type=import_error, input_value='foo.bar', input_type=str]
            '''

        # Actual python objects can be assigned as well
        my_cos = ImportThings(obj=math.cos)
        my_cos_2 = ImportThings(obj='math.cos')
        my_cos_3 = ImportThings(obj='math:cos')
        assert my_cos == my_cos_2 == my_cos_3

        # You can set default field value either as Python object:
        class ImportThingsDefaultPyObj(BaseModel):
            obj: ImportString = math.cos

        # or as a string value (but only if used with `validate_default=True`)
        class ImportThingsDefaultString(BaseModel):
            obj: ImportString = Field(default='math.cos', validate_default=True)

        my_cos_default1 = ImportThingsDefaultPyObj()
        my_cos_default2 = ImportThingsDefaultString()
        assert my_cos_default1.obj == my_cos_default2.obj == math.cos

        # note: this will not work!
        class ImportThingsMissingValidateDefault(BaseModel):
            obj: ImportString = 'math.cos'

        my_cos_default3 = ImportThingsMissingValidateDefault()
        assert my_cos_default3.obj == 'math.cos'  # just string, not evaluated
        ```

        Serializing an `ImportString` type to json is also possible.

        ```python
        from pydantic import BaseModel, ImportString

        class ImportThings(BaseModel):
            obj: ImportString

        # Create an instance
        m = ImportThings(obj='math.cos')
        print(m)
        #> obj=<built-in function cos>
        print(m.model_dump_json())
        #> {"obj":"math.cos"}
        ```
        r   itemrx   c                 C  s   t ||  f S ry   r"   clsr   r}   r}   r~   __class_getitem__  s    zImportString.__class_getitem__	type[Any]r0   core_schema.CoreSchemasourcehandlerrx   c                 C  sB   t j| jdd}| |kr(t jtj|dS t jtj|||dS d S )Njson)	when_used)functionserializationr   schemar   )r!   $plain_serializer_function_ser_schema
_serializeZ no_info_plain_validator_functionr.   Zimport_stringZ!no_info_before_validator_function)r   r   r   Z
serializerr}   r}   r~   __get_pydantic_core_schema__  s       z)ImportString.__get_pydantic_core_schema__r   r1   r4   )csr   rx   c                 C  s   |t  S ry   )r!   
str_schema)r   r   r   r}   r}   r~   __get_pydantic_json_schema__  s    z)ImportString.__get_pydantic_json_schema__r
   r   )vrx   c                 C  st   t | tr| jS t| dr6t| dr6| j d| j S t| drl| jdkrNdS | jdkr\dS | jd	krpd
S n| S d S )Nr   r   .namez<stdout>z
sys.stdoutz<stdin>z	sys.stdinz<stderr>z
sys.stderr)
isinstancer   r   hasattrr   r   )r   r}   r}   r~   r     s    




zImportString._serializerw   c                 C  s   dS )Nr>   r}   r{   r}   r}   r~   __repr__  s    zImportString.__repr__N)r   r   r   r   classmethodr   r   r   staticmethodr   r   r}   r}   r}   r~   r>     s   Or>   	ru   r   r   r   r   r   
max_digitsdecimal_placesr   zint | Decimal | Noneztype[Decimal])
ru   r   r   r   r   r   r   r   r   rx   c        	   	   	   C  s^   t t| dk	rt| ndtj||||d|dk	r8t|ndtj||d|dk	rVt|ndf S )a
  
    !!! warning "Discouraged"
        This function is **discouraged** in favor of using
        [`Annotated`](https://docs.python.org/3/library/typing.html#typing.Annotated) with
        [`Field`][pydantic.fields.Field] instead.

        This function will be **deprecated** in Pydantic 3.0.

        The reason is that `condecimal` returns a type, which doesn't play well with static analysis tools.

        === ":x: Don't do this"
            ```python
            from pydantic import BaseModel, condecimal

            class Foo(BaseModel):
                bar: condecimal(strict=True, allow_inf_nan=True)
            ```

        === ":white_check_mark: Do this"
            ```python
            from decimal import Decimal

            from typing_extensions import Annotated

            from pydantic import BaseModel, Field

            class Foo(BaseModel):
                bar: Annotated[Decimal, Field(strict=True, allow_inf_nan=True)]
            ```

    A wrapper around Decimal that adds validation.

    Args:
        strict: Whether to validate the value in strict mode. Defaults to `None`.
        gt: The value must be greater than this. Defaults to `None`.
        ge: The value must be greater than or equal to this. Defaults to `None`.
        lt: The value must be less than this. Defaults to `None`.
        le: The value must be less than or equal to this. Defaults to `None`.
        multiple_of: The value must be a multiple of this. Defaults to `None`.
        max_digits: The maximum number of digits. Defaults to `None`.
        decimal_places: The number of decimal places. Defaults to `None`.
        allow_inf_nan: Whether to allow infinity and NaN. Defaults to `None`.

    ```python
    from decimal import Decimal

    from pydantic import BaseModel, ValidationError, condecimal

    class ConstrainedExample(BaseModel):
        constrained_decimal: condecimal(gt=Decimal('1.0'))

    m = ConstrainedExample(constrained_decimal=Decimal('1.1'))
    print(repr(m))
    #> ConstrainedExample(constrained_decimal=Decimal('1.1'))

    try:
        ConstrainedExample(constrained_decimal=Decimal('0.9'))
    except ValidationError as e:
        print(e.errors())
        '''
        [
            {
                'type': 'greater_than',
                'loc': ('constrained_decimal',),
                'msg': 'Input should be greater than 1.0',
                'input': Decimal('0.9'),
                'ctx': {'gt': Decimal('1.0')},
                'url': 'https://errors.pydantic.dev/2/v/greater_than',
            }
        ]
        '''
    ```
    Nr   )r   r   )	r"   r   r6   r   r   r   r*   r   rc   r   r}   r}   r~   rJ     s    UrJ   c                   @  sL   e Zd ZU dZded< dddddd	Zd
dddddZddddZdS )UuidVersiona'  A field metadata class to indicate a [UUID](https://docs.python.org/3/library/uuid.html) version.

    Use this class as an annotation via [`Annotated`](https://docs.python.org/3/library/typing.html#typing.Annotated), as seen below.

    Attributes:
        uuid_version: The version of the UUID. Must be one of 1, 3, 4, or 5.

    Example:
        ```python
        from uuid import UUID

        from typing_extensions import Annotated

        from pydantic.types import UuidVersion

        UUID1 = Annotated[UUID, UuidVersion(1)]
        ```
    zLiteral[(1, 3, 4, 5)]uuid_versionr   r1   r4   r!   r   rx   c                 C  s.   ||}| dd  |jdd| j d |S )NZanyOfstringuuidtypeformat)popupdater   r|   r!   r   field_schemar}   r}   r~   r     s    z(UuidVersion.__get_pydantic_json_schema__r
   r0   r   c                 C  sF   t | |rtj| jdS ||}t|d d| jj | j|d< |S d S )N)versionr   r   r   )r   r!   Zuuid_schemar   _check_annotated_type	__class__r   r|   r   r   r   r}   r}   r~   r     s    

z(UuidVersion.__get_pydantic_core_schema__rv   rw   c                 C  s   t t| jS ry   )rz   r   r   r{   r}   r}   r~   r     s    zUuidVersion.__hash__N)r   r   r   r   r   r   r   r   r}   r}   r}   r~   r   n  s
   
r            c                   @  s   e Zd ZU ded< ddddddZd	d
ddddZeddddddZeddddddZeddddddZ	eddddddZ
ddddZdS )PathTypez)Literal[('file', 'dir', 'new', 'socket')]	path_typer   r1   r4   r   c                 C  s.   ||}ddd}|j || jddd |S )Nz	file-pathzdirectory-path)filedirpathr   )r   r   )r   getr   )r|   r!   r   r   Zformat_conversionr}   r}   r~   r     s    
z%PathType.__get_pydantic_json_schema__r
   r0   r   c                 C  sL   t tj| jt tj| jt tj| jt tj| jd}t|| j ||S )N)r   r   newsocket)	r   r!   ZWithInfoValidatorFunctionvalidate_filevalidate_directoryvalidate_newvalidate_socket"with_info_after_validator_functionr   )r|   r   r   Zfunction_lookupr}   r}   r~   r     s    z%PathType.__get_pydantic_core_schema__r   core_schema.ValidationInfo)r   _rx   c                 C  s   |   r| S tddd S )NZpath_not_filezPath does not point to a file)is_filer   r   r   r}   r}   r~   r     s    zPathType.validate_filec                 C  s   |   r| S tddd S )NZpath_not_socketzPath does not point to a socket)Z	is_socketr   r   r}   r}   r~   r     s    zPathType.validate_socketc                 C  s   |   r| S tddd S )NZpath_not_directoryz"Path does not point to a directory)is_dirr   r   r}   r}   r~   r      s    zPathType.validate_directoryc                 C  s2   |   rtddn| j  s*tddn| S d S )NZpath_existszPath already existsZparent_does_not_existzParent directory does not exist)existsr   parentr   r}   r}   r~   r     s
    
zPathType.validate_newrv   rw   c                 C  s   t t| jS ry   )rz   r   r   r{   r}   r}   r~   r     s    zPathType.__hash__N)r   r   r   r   r   r   r   r   r   r   r   r   r}   r}   r}   r~   r     s   
r   r   r   r   r   c                   @  sf   e Zd ZdZedddddZedddd	d
dZddddZddddZdddddZ	dS )rR   a0
  A special type wrapper which loads JSON before parsing.

        You can use the `Json` data type to make Pydantic first load a raw JSON string before
        validating the loaded data into the parametrized type:

        ```python
        from typing import Any, List

        from pydantic import BaseModel, Json, ValidationError

        class AnyJsonModel(BaseModel):
            json_obj: Json[Any]

        class ConstrainedJsonModel(BaseModel):
            json_obj: Json[List[int]]

        print(AnyJsonModel(json_obj='{"b": 1}'))
        #> json_obj={'b': 1}
        print(ConstrainedJsonModel(json_obj='[1, 2, 3]'))
        #> json_obj=[1, 2, 3]

        try:
            ConstrainedJsonModel(json_obj=12)
        except ValidationError as e:
            print(e)
            '''
            1 validation error for ConstrainedJsonModel
            json_obj
              JSON input should be string, bytes or bytearray [type=json_type, input_value=12, input_type=int]
            '''

        try:
            ConstrainedJsonModel(json_obj='[a, b]')
        except ValidationError as e:
            print(e)
            '''
            1 validation error for ConstrainedJsonModel
            json_obj
              Invalid JSON: expected value at line 1 column 2 [type=json_invalid, input_value='[a, b]', input_type=str]
            '''

        try:
            ConstrainedJsonModel(json_obj='["a", "b"]')
        except ValidationError as e:
            print(e)
            '''
            2 validation errors for ConstrainedJsonModel
            json_obj.0
              Input should be a valid integer, unable to parse string as an integer [type=int_parsing, input_value='a', input_type=str]
            json_obj.1
              Input should be a valid integer, unable to parse string as an integer [type=int_parsing, input_value='b', input_type=str]
            '''
        ```

        When you dump the model using `model_dump` or `model_dump_json`, the dumped value will be the result of validation,
        not the original JSON string. However, you can use the argument `round_trip=True` to get the original JSON string back:

        ```python
        from typing import List

        from pydantic import BaseModel, Json

        class ConstrainedJsonModel(BaseModel):
            json_obj: Json[List[int]]

        print(ConstrainedJsonModel(json_obj='[1, 2, 3]').model_dump_json())
        #> {"json_obj":[1,2,3]}
        print(
            ConstrainedJsonModel(json_obj='[1, 2, 3]').model_dump_json(round_trip=True)
        )
        #> {"json_obj":"[1,2,3]"}
        ```
        r   r   c                 C  s   t ||  f S ry   r   r   r}   r}   r~   r     s    zJson.__class_getitem__r
   r0   r   r   c                 C  s$   | |krt d S t ||S d S ry   )r!   json_schemar   r   r   r}   r}   r~   r     s    
z!Json.__get_pydantic_core_schema__r   rw   c                 C  s   dS )NrR   r}   r{   r}   r}   r~   r     s    zJson.__repr__rv   c                 C  s   t t| S ry   )rz   r   r{   r}   r}   r~   r     s    zJson.__hash__rt   otherrx   c                 C  s   t |t | kS ry   )r   r|   r   r}   r}   r~   __eq__  s    zJson.__eq__N)
r   r   r   r   r   r   r   r   r   r   r}   r}   r}   r~   rR   v  s   JrR   
SecretTypec                   @  sr   e Zd ZdddddZddddZd	d
dddZddddZddddZddddZddddZ	dS )_SecretBaser   None)secret_valuerx   c                 C  s
   || _ d S ry   _secret_value)r|   r   r}   r}   r~   __init__  s    z_SecretBase.__init__rw   c                 C  s   | j S )zNGet the secret value.

        Returns:
            The secret value.
        r   r{   r}   r}   r~   get_secret_value  s    z_SecretBase.get_secret_valuer
   rt   r   c                 C  s   t || jo|  | kS ry   )r   r   r  r   r}   r}   r~   r     s    z_SecretBase.__eq__rv   c                 C  s   t |  S ry   )rz   r  r{   r}   r}   r~   r     s    z_SecretBase.__hash__r   c                 C  s   t |  S ry   )r   _displayr{   r}   r}   r~   __str__  s    z_SecretBase.__str__c                 C  s   | j j d|  dS )N())r   r   r  r{   r}   r}   r~   r     s    z_SecretBase.__repr__str | bytesc                 C  s   t d S ry   )NotImplementedErrorr{   r}   r}   r~   r    s    z_SecretBase._displayN)
r   r   r   r   r  r   r   r  r   r  r}   r}   r}   r~   r     s   r   Secret[SecretType]zcore_schema.SerializationInfozstr | Secret[SecretType])valueinforx   c                 C  s   |j dkrt| S | S d S Nr   )moder   r	  r
  r}   r}   r~   _serialize_secret  s    
r  c                   @  sP   e Zd ZdZddddZedddd	d
dZeej	ej
eddddZdS )rS   a  A generic base class used for defining a field with sensitive information that you do not want to be visible in logging or tracebacks.

    You may either directly parametrize `Secret` with a type, or subclass from `Secret` with a parametrized type. The benefit of subclassing
    is that you can define a custom `_display` method, which will be used for `repr()` and `str()` methods. The examples below demonstrate both
    ways of using `Secret` to create a new secret type.

    1. Directly parametrizing `Secret` with a type:

    ```python
    from pydantic import BaseModel, Secret

    SecretBool = Secret[bool]

    class Model(BaseModel):
        secret_bool: SecretBool

    m = Model(secret_bool=True)
    print(m.model_dump())
    #> {'secret_bool': Secret('**********')}

    print(m.model_dump_json())
    #> {"secret_bool":"**********"}

    print(m.secret_bool.get_secret_value())
    #> True
    ```

    2. Subclassing from parametrized `Secret`:

    ```python
    from datetime import date

    from pydantic import BaseModel, Secret

    class SecretDate(Secret[date]):
        def _display(self) -> str:
            return '****/**/**'

    class Model(BaseModel):
        secret_date: SecretDate

    m = Model(secret_date=date(2022, 1, 1))
    print(m.model_dump())
    #> {'secret_date': SecretDate('****/**/**')}

    print(m.model_dump_json())
    #> {"secret_date":"****/**/**"}

    print(m.secret_date.get_secret_value())
    #> 2022-01-01
    ```

    The value returned by the `_display` method will be used for `repr()` and `str()`.

    You can enforce constraints on the underlying type through annotations:
    For example:

    ```python
    from typing_extensions import Annotated

    from pydantic import BaseModel, Field, Secret, ValidationError

    SecretPosInt = Secret[Annotated[int, Field(gt=0, strict=True)]]

    class Model(BaseModel):
        sensitive_int: SecretPosInt

    m = Model(sensitive_int=42)
    print(m.model_dump())
    #> {'sensitive_int': Secret('**********')}

    try:
        m = Model(sensitive_int=-42)  # (1)!
    except ValidationError as exc_info:
        print(exc_info.errors(include_url=False, include_input=False))
        '''
        [
            {
                'type': 'greater_than',
                'loc': ('sensitive_int',),
                'msg': 'Input should be greater than 0',
                'ctx': {'gt': 0},
            }
        ]
        '''

    try:
        m = Model(sensitive_int='42')  # (2)!
    except ValidationError as exc_info:
        print(exc_info.errors(include_url=False, include_input=False))
        '''
        [
            {
                'type': 'int_type',
                'loc': ('sensitive_int',),
                'msg': 'Input should be a valid integer',
            }
        ]
        '''
    ```

    1. The input value is not greater than 0, so it raises a validation error.
    2. The input value is not an integer, so it raises a validation error because the `SecretPosInt` type has strict mode enabled.
    r  rw   c                 C  s   |   rdS dS Nz
********** )r  r{   r}   r}   r~   r  h  s    zSecret._displayr   r0   r   r   c           	        s   d }t |}|d k	r"t|d }nXt dt dg }|D ]}t |tkr:t|d }q:|g ksh|d krztd j d||}dd fdd	}tjt	||t
 fd
d|tjtddddS )Nr   __orig_bases__	__bases__zCan't get secret type from zE. Please use Secret[<type>], or subclass from Secret[<type>] instead.r  rw   c                   s"   t | tr|  } || } |S ry   )r   rS   r  )r	  r   Zvalidated_innerr   r}   r~   validate_secret_value  s    
zBSecret.__get_pydantic_core_schema__.<locals>.validate_secret_valuec                   s    | S ry   r}   )xr  r}   r~   <lambda>      z5Secret.__get_pydantic_core_schema__.<locals>.<lambda>TalwaysZinfo_argr   python_schemar   r   )r   r   getattrrS   	TypeErrorr   Zgenerate_schemar!   json_or_python_schemaZno_info_wrap_validator_function no_info_after_validator_functionr   r  )	r   r   r   Z
inner_typeZorigin_typebasesbaseZinner_schemar  r}   r  r~   r   k  s4    
z#Secret.__get_pydantic_core_schema__Tr  r  r   N)r   r   r   r   r  r   r   r    r!   
any_schemar   r  __pydantic_serializer__r}   r}   r}   r~   rS     s   i'rS   r   r	  rx   c                 C  s   | rdS dS r  r}   r	  r}   r}   r~   _secret_display  s    r'  z_SecretField[SecretType]zstr | _SecretField[SecretType]c                 C  s   |j dkrt|  S | S d S r  )r  r'  r  r  r}   r}   r~   _serialize_secret_field  s    
r(  c                   @  sP   e Zd ZU ded< ded< eddddd	d
Zeejej	e
ddddZdS )_SecretFieldClassVar[CoreSchema]_inner_schemaClassVar[str]_error_kindr   r0   r   r   c                   s^   dddd fdd}t  jddd	 fd
d}t j|dd|ddd|gidS )Nr   r1   r4   )_core_schemar   rx   c                   s    | j }tj|dddd |S )Nr   TZpassword)r   Z	writeOnlyr   )r+  r-   Zupdate_not_none)r.  r   r   r  r}   r~   get_json_schema  s    
zB_SecretField.__get_pydantic_core_schema__.<locals>.get_json_schemart   r   )ru   rx   c                   s4   t jt jt g j| dt jtddddS )N)custom_error_typeru   Tr  r  r  )r!   r  union_schemaZis_instance_schemar-  r   r(  ru   r   r   r   r}   r~   get_secret_schema  s    zD_SecretField.__get_pydantic_core_schema__.<locals>.get_secret_schemaFr2  TZpydantic_js_functions)Z
lax_schemaZstrict_schemametadata)r!   r  r+  Zlax_or_strict_schema)r   r   r   r/  r4  r}   r3  r~   r     s    
z)_SecretField.__get_pydantic_core_schema__Tr  r  r"  N)r   r   r   r   r   r   r    r!   r#  r   r(  r$  r}   r}   r}   r~   r)    s   
(r)  c                   @  sJ   e Zd ZU dZe Zded< dZded< ddd	d
Z	ddddZ
dS )rT   a  A string used for storing sensitive information that you do not want to be visible in logging or tracebacks.

    When the secret value is nonempty, it is displayed as `'**********'` instead of the underlying value in
    calls to `repr()` and `str()`. If the value _is_ empty, it is displayed as `''`.

    ```python
    from pydantic import BaseModel, SecretStr

    class User(BaseModel):
        username: str
        password: SecretStr

    user = User(username='scolvin', password='password1')

    print(user)
    #> username='scolvin' password=SecretStr('**********')
    print(user.password.get_secret_value())
    #> password1
    print((SecretStr('password'), SecretStr('')))
    #> (SecretStr('**********'), SecretStr(''))
    ```

    As seen above, by default, [`SecretStr`][pydantic.types.SecretStr] (and [`SecretBytes`][pydantic.types.SecretBytes])
    will be serialized as `**********` when serializing to json.

    You can use the [`field_serializer`][pydantic.functional_serializers.field_serializer] to dump the
    secret as plain-text when serializing to json.

    ```python
    from pydantic import BaseModel, SecretBytes, SecretStr, field_serializer

    class Model(BaseModel):
        password: SecretStr
        password_bytes: SecretBytes

        @field_serializer('password', 'password_bytes', when_used='json')
        def dump_secret(self, v):
            return v.get_secret_value()

    model = Model(password='IAmSensitive', password_bytes=b'IAmSensitiveBytes')
    print(model)
    #> password=SecretStr('**********') password_bytes=SecretBytes(b'**********')
    print(model.password)
    #> **********
    print(model.model_dump())
    '''
    {
        'password': SecretStr('**********'),
        'password_bytes': SecretBytes(b'**********'),
    }
    '''
    print(model.model_dump_json())
    #> {"password":"IAmSensitive","password_bytes":"IAmSensitiveBytes"}
    ```
    r*  r+  Zstring_typer,  r-  rv   rw   c                 C  s
   t | jS ry   lenr   r{   r}   r}   r~   __len__!  s    zSecretStr.__len__r   c                 C  s
   t | jS ry   )r'  r   r{   r}   r}   r~   r  $  s    zSecretStr._displayN)r   r   r   r   r!   r   r+  r   r-  r8  r  r}   r}   r}   r~   rT     s
   
8rT   c                   @  sJ   e Zd ZU dZe Zded< dZded< ddd	d
Z	ddddZ
dS )rU   aN  A bytes used for storing sensitive information that you do not want to be visible in logging or tracebacks.

    It displays `b'**********'` instead of the string value on `repr()` and `str()` calls.
    When the secret value is nonempty, it is displayed as `b'**********'` instead of the underlying value in
    calls to `repr()` and `str()`. If the value _is_ empty, it is displayed as `b''`.

    ```python
    from pydantic import BaseModel, SecretBytes

    class User(BaseModel):
        username: str
        password: SecretBytes

    user = User(username='scolvin', password=b'password1')
    #> username='scolvin' password=SecretBytes(b'**********')
    print(user.password.get_secret_value())
    #> b'password1'
    print((SecretBytes(b'password'), SecretBytes(b'')))
    #> (SecretBytes(b'**********'), SecretBytes(b''))
    ```
    r*  r+  Z
bytes_typer,  r-  rv   rw   c                 C  s
   t | jS ry   r6  r{   r}   r}   r~   r8  B  s    zSecretBytes.__len__r   c                 C  s   t | j S ry   )r'  r   encoder{   r}   r}   r~   r  E  s    zSecretBytes._displayN)r   r   r   r   r!   Zbytes_schemar+  r   r-  r8  r  r}   r}   r}   r~   rU   (  s
   
rU   c                   @  s*   e Zd ZdZdZdZdZddddZd	S )
PaymentCardBrandzAmerican ExpressZ
MastercardZVisar   r   rw   c                 C  s   | j S ry   r&  r{   r}   r}   r~   r  R  s    zPaymentCardBrand.__str__N)r   r   r   amex
mastercardvisar   r  r}   r}   r}   r~   r:  L  s
   r:  zThe `PaymentCardNumber` class is deprecated, use `pydantic_extra_types` instead. See https://docs.pydantic.dev/latest/api/pydantic_extra_types_payment/#pydantic_extra_types.payment.PaymentCardNumber.)categoryc                   @  s   e Zd ZU dZdZded< dZded< dZded	< d
ed< d
ed< ded< d
dddZe	ddddddZ
e	dd
d dddZed
dddZe	d
dd d!d"Ze	d
d
d d#d$Zed
dd d%d&Zd'S )(rZ   z<Based on: https://en.wikipedia.org/wiki/Payment_card_number.TzClassVar[bool]r      zClassVar[int]r      r   r   binlast4r:  brand)card_numberc                 C  s@   |  | | |}|d d | _|dd  | _| || _d S )N   )validate_digitsvalidate_luhn_check_digitrA  rB  validate_brandrC  )r|   rD  r}   r}   r~   r   e  s
    

zPaymentCardNumber.__init__r   r0   r   r   c                 C  s    t | jt j| j| j| jdS )N)r   r   r   )r!   r   validater   r   r   r   r   r}   r}   r~   r   n  s      z.PaymentCardNumber.__get_pydantic_core_schema__r   r   input_valuerx   c                C  s   | |S )zCValidate the card number and return a `PaymentCardNumber` instance.r}   )r   rL  r   r}   r}   r~   rJ  w  s    zPaymentCardNumber.validaterw   c                 C  s$   t | d }| j d|  | j S )zvMask all but the last 4 digits of the card number.

        Returns:
            A masked card number string.
        
   *)r7  rA  rB  )r|   Z
num_maskedr}   r}   r~   masked|  s    zPaymentCardNumber.maskedr   )rD  rx   c                 C  s   |  stdddS )z,Validate that the card number is all digits.Zpayment_card_number_digitszCard number is not all digitsN)isdigitr   )r   rD  r}   r}   r~   rG    s    z!PaymentCardNumber.validate_digitsc                 C  s   t |d }t|}|d }t|d D ]<}t || }|d |krL|d9 }|dkr\|d8 }||7 }q(|d dk}|stdd|S )	z7Based on: https://en.wikipedia.org/wiki/Luhn_algorithm.   r(   	   rM  r   Zpayment_card_number_luhnzCard number is not luhn valid)rv   r7  ranger   )r   rD  Zsum_lengthZparityidigitvalidr}   r}   r~   rH    s    

z+PaymentCardNumber.validate_luhn_check_digitc                 C  s   | d dkrt j}nJdt| dd   kr4dkr@n nt j}n| dd dkrXt j}nt j}d}|t jkr~d}t| |k}n<|t jkrd	}t| d
k}n |t jkrd}t| |k}nd}|stdd||d|S )zValidate length based on BIN for major brands:
        https://en.wikipedia.org/wiki/Payment_card_number#Issuer_identification_number_(IIN).
        r   43   NrR  7   >   3437   z13, 16 or 19>   r^  r@        TZpayment_card_number_brandz3Length for a {brand} card must be {required_length})rC  required_length)r:  r=  rv   r<  r;  r   r7  r   )rD  rC  ra  rX  r}   r}   r~   rI    s2    $


z PaymentCardNumber.validate_brandN)r   r   r   r   r   r   r   r   r   r   r   rJ  propertyrO  rG  rH  r   rI  r}   r}   r}   r~   rZ   V  s(   
		rZ   c                   @  s   e Zd ZdZdddddddd	d
ddddddddddddddddddZedd e D  dZe	eej
Zed d!d"d#d$d%Zed&d'd d(d)d*Zd7d-d.d.d/d0d1Zd.d2d3d4d5Zd6S )8r[   a  Converts a string representing a number of bytes with units (such as `'1KB'` or `'11.5MiB'`) into an integer.

    You can use the `ByteSize` data type to (case-insensitively) convert a string representation of a number of bytes into
    an integer, and also to print out human-readable strings representing a number of bytes.

    In conformance with [IEC 80000-13 Standard](https://en.wikipedia.org/wiki/ISO/IEC_80000) we interpret `'1KB'` to mean 1000 bytes,
    and `'1KiB'` to mean 1024 bytes. In general, including a middle `'i'` will cause the unit to be interpreted as a power of 2,
    rather than a power of 10 (so, for example, `'1 MB'` is treated as `1_000_000` bytes, whereas `'1 MiB'` is treated as `1_048_576` bytes).

    !!! info
        Note that `1b` will be parsed as "1 byte" and not "1 bit".

    ```python
    from pydantic import BaseModel, ByteSize

    class MyModel(BaseModel):
        size: ByteSize

    print(MyModel(size=52000).size)
    #> 52000
    print(MyModel(size='3000 KiB').size)
    #> 3072000

    m = MyModel(size='50 PB')
    print(m.size.human_readable())
    #> 44.4PiB
    print(m.size.human_readable(decimal=True))
    #> 50.0PB
    print(m.size.human_readable(separator=' '))
    #> 44.4 PiB

    print(m.size.to('TiB'))
    #> 45474.73508864641
    ```
    r(     i@B i ʚ;l    J)l     I5 l     NZo   i   i   @l        l           l            g      ?g     @_@g    @g    e͝Ag   =Bg  4&kBg Ngm{Cg      `@g       Ag      Ag      @Bg      Bg      C)bZkbZmbZgbtbZpbZebZkibZmibZgibZtibZpibZeibbitZkbitZmbitZgbitZtbitZpbitZebitZkibitZmibitZgibitZtibitZpibitZeibitc                 C  s&   i | ]\}}d |kr|  d |qS )rV  r   )lower).0kr   r}   r}   r~   
<dictcomp>  s      
 zByteSize.<dictcomp>z^\s*(\d*\.?\d+)\s*(\w+)?r   r0   r   r   c                 C  sF   t j| jt jt j| jdt jddgdddt jtt jddddS )	N)r   r   )r   	byte_size/could not parse value and unit from byte stringr0  custom_error_message)Zreturn_schemar   )	r!   r   	_validater1  r   byte_string_patternZ
int_schemar   rv   r   r}   r}   r~   r     s    
 
z%ByteSize.__get_pydantic_core_schema__r   r
   rK  c                C  s   z| t |W S  tk
r"   Y nX | jt|}|d krFtdd| \}}|d kr^d}z| j|  }W n$ t	k
r   tddd|iY nX | t t
|| S )Nrl  rm  re  byte_size_unitz%could not interpret byte unit: {unit}unit)rv   
ValueErrorbyte_string_rematchr   r   groups
byte_sizesrh  KeyErrorr   )r   rL  r   Z	str_matchZscalarrs  Z	unit_multr}   r}   r~   rp    s    
zByteSize._validateFr  rt   r   )decimal	separatorrx   c                 C  s   |rd}d}d}nd}d}d}t | }|D ]L}t||k rn|dkrX|d| |   S |d	| |   S || }q*|d	| | S )
a  Converts a byte size to a human readable string.

        Args:
            decimal: If True, use decimal units (e.g. 1000 bytes per KB). If False, use binary units
                (e.g. 1024 bytes per KiB).
            separator: A string used to split the value and unit. Defaults to an empty string ('').

        Returns:
            A human readable string representation of the byte size.
        rc  )BZKBZMBZGBZTBZPBZEBrd  )r|  ZKiBZMiBZGiBZTiBZPiBZEiBr|  z0.0fz0.1f)r   abs)r|   rz  r{  ZdivisorZunitsZ
final_unitZnumrs  r}   r}   r~   human_readable2  s    
zByteSize.human_readabler   )rs  rx   c                 C  s@   z| j |  }W n$ tk
r6   tddd|iY nX | | S )a  Converts a byte size to another unit, including both byte and bit units.

        Args:
            unit: The unit to convert to. Must be one of the following: B, KB, MB, GB, TB, PB, EB,
                KiB, MiB, GiB, TiB, PiB, EiB (byte units) and
                bit, kbit, mbit, gbit, tbit, pbit, ebit,
                kibit, mibit, gibit, tibit, pibit, eibit (bit units).

        Returns:
            The byte size in the new unit.
        rr  z%Could not interpret byte unit: {unit}rs  )rx  rh  ry  r   )r|   rs  Zunit_divr}   r}   r~   toQ  s
    zByteSize.toN)Fr  )r   r   r   r   rx  r   itemsrq  recompile
IGNORECASEru  r   r   rp  r~  r  r}   r}   r}   r~   r[     sJ   %r[   r   )annotated_typeexpected_type
annotationrx   c                 C  s&   | |kr"t d| d|  dddd S )N'z' cannot annotate 'z'.zinvalid-annotated-typer   r2   )r  r  r  r}   r}   r~   r   h  s    r   c                   @  s4   e Zd ZdZeddddddZdd	d
dZdS )r\   zA date in the past.r   r0   r   r   c                 C  s>   | |krt jddS ||}t|d d| j d|d< |S d S )Npastnow_opr   r   r  r!   Zdate_schemar   r   r   r   r   r   r}   r}   r~   r   u  s    z%PastDate.__get_pydantic_core_schema__r   rw   c                 C  s   dS )Nr\   r}   r{   r}   r}   r~   r     s    zPastDate.__repr__Nr   r   r   r   r   r   r   r}   r}   r}   r~   r\   r  s   r\   c                   @  s4   e Zd ZdZeddddddZdd	d
dZdS )r]   zA date in the future.r   r0   r   r   c                 C  s>   | |krt jddS ||}t|d d| j d|d< |S d S )Nfuturer  r   r   r  r  r  r}   r}   r~   r     s    z'FutureDate.__get_pydantic_core_schema__r   rw   c                 C  s   dS )Nr]   r}   r{   r}   r}   r~   r     s    zFutureDate.__repr__Nr  r}   r}   r}   r~   r]     s   r]   ru   r   r   r   r   zdate | Nonez
type[date])ru   r   r   r   r   rx   c              	   C  s,   t t| dk	rt| ndtj||||df S )a  A wrapper for date that adds constraints.

    Args:
        strict: Whether to validate the date value in strict mode. Defaults to `None`.
        gt: The value must be greater than this. Defaults to `None`.
        ge: The value must be greater than or equal to this. Defaults to `None`.
        lt: The value must be less than this. Defaults to `None`.
        le: The value must be less than or equal to this. Defaults to `None`.

    Returns:
        A date type with the specified constraints.
    Nr   )r"   r   r6   r   r   r  r}   r}   r~   r`     s    r`   c                   @  s4   e Zd ZdZeddddddZdd	d
dZdS )ra   z'A datetime that requires timezone info.r   r0   r   r   c                 C  s>   | |krt jddS ||}t|d d| j d|d< |S d S )NZawaretz_constraintr   r   r  r!   Zdatetime_schemar   r   r  r}   r}   r~   r     s    z*AwareDatetime.__get_pydantic_core_schema__r   rw   c                 C  s   dS )Nra   r}   r{   r}   r}   r~   r     s    zAwareDatetime.__repr__Nr  r}   r}   r}   r~   ra     s   ra   c                   @  s4   e Zd ZdZeddddddZdd	d
dZdS )rb   z.A datetime that doesn't require timezone info.r   r0   r   r   c                 C  s>   | |krt jddS ||}t|d d| j d|d< |S d S )NZnaiver  r   r   r  r  r  r}   r}   r~   r     s    z*NaiveDatetime.__get_pydantic_core_schema__r   rw   c                 C  s   dS )Nrb   r}   r{   r}   r}   r~   r     s    zNaiveDatetime.__repr__Nr  r}   r}   r}   r~   rb     s   rb   c                   @  s4   e Zd ZdZeddddddZdd	d
dZdS )r^   z$A datetime that must be in the past.r   r0   r   r   c                 C  s>   | |krt jddS ||}t|d d| j d|d< |S d S )Nr  r  r   r   r  r  r  r}   r}   r~   r     s    z)PastDatetime.__get_pydantic_core_schema__r   rw   c                 C  s   dS )Nr^   r}   r{   r}   r}   r~   r     s    zPastDatetime.__repr__Nr  r}   r}   r}   r~   r^     s   r^   c                   @  s4   e Zd ZdZeddddddZdd	d
dZdS )r_   z&A datetime that must be in the future.r   r0   r   r   c                 C  s>   | |krt jddS ||}t|d d| j d|d< |S d S )Nr  r  r   r   r  r  r  r}   r}   r~   r     s    z+FutureDatetime.__get_pydantic_core_schema__r   rw   c                 C  s   dS )Nr_   r}   r{   r}   r}   r~   r   	  s    zFutureDatetime.__repr__Nr  r}   r}   r}   r~   r_     s   r_   c                   @  sJ   e Zd ZdZedddddZedddddZed	d
ddZdS )rd   z:Protocol for encoding and decoding data to and from bytes.r   datarx   c                 C  s   dS )zDecode the data using the encoder.

        Args:
            data: The data to decode.

        Returns:
            The decoded data.
        Nr}   )r   r  r}   r}   r~   decode	  s    
zEncoderProtocol.decoder%  c                 C  s   dS )zEncode the data using the encoder.

        Args:
            value: The data to encode.

        Returns:
            The encoded data.
        Nr}   r   r	  r}   r}   r~   r9  	  s    
zEncoderProtocol.encoder   rw   c                 C  s   dS )vGet the JSON format for the encoded data.

        Returns:
            The JSON format for the encoded data.
        Nr}   r  r}   r}   r~   get_json_format)	  s    zEncoderProtocol.get_json_formatNr   r   r   r   r   r  r9  r  r}   r}   r}   r~   rd   	  s   rd   c                   @  sJ   e Zd ZdZedddddZedddddZed	d
ddZdS )rg   z'Standard (non-URL-safe) Base64 encoder.r   r  c              
   C  sH   zt |W S  tk
rB } ztdddt|iW 5 d}~X Y nX dS zDecode the data from base64 encoded bytes to original bytes data.

        Args:
            data: The data to decode.

        Returns:
            The decoded data.
        Zbase64_decodez Base64 decoding error: '{error}'errorN)base64Z	b64decodert  r   r   r   r  er}   r}   r~   r  6	  s    
zBase64Encoder.decoder%  c                 C  s
   t |S zEncode the data from bytes to a base64 encoded bytes.

        Args:
            value: The data to encode.

        Returns:
            The encoded data.
        )r  Z	b64encoder  r}   r}   r~   r9  E	  s    
zBase64Encoder.encodezLiteral['base64']rw   c                 C  s   dS )r  r  r}   r  r}   r}   r~   r  Q	  s    zBase64Encoder.get_json_formatNr  r}   r}   r}   r~   rg   3	  s   rg   c                   @  sJ   e Zd ZdZedddddZedddddZed	d
ddZdS )Base64UrlEncoderzURL-safe Base64 encoder.r   r  c              
   C  sH   zt |W S  tk
rB } ztdddt|iW 5 d}~X Y nX dS r  )r  Zurlsafe_b64decodert  r   r   r  r}   r}   r~   r  ^	  s    
zBase64UrlEncoder.decoder%  c                 C  s
   t |S r  )r  Zurlsafe_b64encoder  r}   r}   r~   r9  m	  s    
zBase64UrlEncoder.encodezLiteral['base64url']rw   c                 C  s   dS )r  Z	base64urlr}   r  r}   r}   r~   r  y	  s    z Base64UrlEncoder.get_json_formatNr  r}   r}   r}   r~   r  [	  s   r  c                   @  sn   e Zd ZU dZded< dddddd	Zd
dddddZddddddZdddddZddddZ	dS )re   a  A bytes type that is encoded and decoded using the specified encoder.

    `EncodedBytes` needs an encoder that implements `EncoderProtocol` to operate.

    ```python
    from typing_extensions import Annotated

    from pydantic import BaseModel, EncodedBytes, EncoderProtocol, ValidationError

    class MyEncoder(EncoderProtocol):
        @classmethod
        def decode(cls, data: bytes) -> bytes:
            if data == b'**undecodable**':
                raise ValueError('Cannot decode data')
            return data[13:]

        @classmethod
        def encode(cls, value: bytes) -> bytes:
            return b'**encoded**: ' + value

        @classmethod
        def get_json_format(cls) -> str:
            return 'my-encoder'

    MyEncodedBytes = Annotated[bytes, EncodedBytes(encoder=MyEncoder)]

    class Model(BaseModel):
        my_encoded_bytes: MyEncodedBytes

    # Initialize the model with encoded data
    m = Model(my_encoded_bytes=b'**encoded**: some bytes')

    # Access decoded value
    print(m.my_encoded_bytes)
    #> b'some bytes'

    # Serialize into the encoded form
    print(m.model_dump())
    #> {'my_encoded_bytes': b'**encoded**: some bytes'}

    # Validate encoded data
    try:
        Model(my_encoded_bytes=b'**undecodable**')
    except ValidationError as e:
        print(e)
        '''
        1 validation error for Model
        my_encoded_bytes
          Value error, Cannot decode data [type=value_error, input_value=b'**undecodable**', input_type=bytes]
        '''
    ```
    type[EncoderProtocol]encoderr   r1   r4   r   c                 C  s    ||}|j d| j d |S Nr   r   r   r  r  r   r}   r}   r~   r   	  s    z)EncodedBytes.__get_pydantic_json_schema__r   r0   r   c                 C  s8   ||}t |d d| jj tj| j|tj| jddS )Nr   r   r   r   )r   r   r   r!   r   r  r   r9  r   r}   r}   r~   r   	  s    z)EncodedBytes.__get_pydantic_core_schema__r   r   r  r   rx   c                 C  s   | j |S zDecode the data using the specified encoder.

        Args:
            data: The data to decode.

        Returns:
            The decoded data.
        )r  r  r|   r  r   r}   r}   r~   r  	  s    	zEncodedBytes.decoder%  c                 C  s   | j |S zEncode the data using the specified encoder.

        Args:
            value: The data to encode.

        Returns:
            The encoded data.
        )r  r9  r|   r	  r}   r}   r~   r9  	  s    	zEncodedBytes.encoderv   rw   c                 C  s
   t | jS ry   rz   r  r{   r}   r}   r~   r   	  s    zEncodedBytes.__hash__N)
r   r   r   r   r   r   r   r  r9  r   r}   r}   r}   r~   re   	  s   
5	re   c                   @  sn   e Zd ZU dZded< dddddd	Zd
dddddZddddddZdddddZddddZ	dS )rf   a  A str type that is encoded and decoded using the specified encoder.

    `EncodedStr` needs an encoder that implements `EncoderProtocol` to operate.

    ```python
    from typing_extensions import Annotated

    from pydantic import BaseModel, EncodedStr, EncoderProtocol, ValidationError

    class MyEncoder(EncoderProtocol):
        @classmethod
        def decode(cls, data: bytes) -> bytes:
            if data == b'**undecodable**':
                raise ValueError('Cannot decode data')
            return data[13:]

        @classmethod
        def encode(cls, value: bytes) -> bytes:
            return b'**encoded**: ' + value

        @classmethod
        def get_json_format(cls) -> str:
            return 'my-encoder'

    MyEncodedStr = Annotated[str, EncodedStr(encoder=MyEncoder)]

    class Model(BaseModel):
        my_encoded_str: MyEncodedStr

    # Initialize the model with encoded data
    m = Model(my_encoded_str='**encoded**: some str')

    # Access decoded value
    print(m.my_encoded_str)
    #> some str

    # Serialize into the encoded form
    print(m.model_dump())
    #> {'my_encoded_str': '**encoded**: some str'}

    # Validate encoded data
    try:
        Model(my_encoded_str='**undecodable**')
    except ValidationError as e:
        print(e)
        '''
        1 validation error for Model
        my_encoded_str
          Value error, Cannot decode data [type=value_error, input_value='**undecodable**', input_type=str]
        '''
    ```
    r  r  r   r1   r4   r   c                 C  s    ||}|j d| j d |S r  r  r   r}   r}   r~   r   
  s    z'EncodedStr.__get_pydantic_json_schema__r   r0   r   c                 C  s8   ||}t |d d| jj tj| j|tj| jddS )Nr   r   r  r   )r   r   r   r!   r   
decode_strr   
encode_strr   r}   r}   r~   r   &
  s    z'EncodedStr.__get_pydantic_core_schema__r   r   r  c                 C  s   | j |  S r  )r  r  r9  r  r}   r}   r~   r  /
  s    	zEncodedStr.decode_strr%  c                 C  s   | j |  S r  )r  r9  r  r  r}   r}   r~   r  :
  s    	zEncodedStr.encode_strrv   rw   c                 C  s
   t | jS ry   r  r{   r}   r}   r~   r   E
  s    zEncodedStr.__hash__N)
r   r   r   r   r   r   r   r  r  r   r}   r}   r}   r~   rf   	  s   
5	rf   )r  c                   @  sD   e Zd ZU dZdZded< dZded< es:ddd	d
dZe	j
Z
dS )rl   aP  Usage docs: https://docs.pydantic.dev/2.10/concepts/types/#using-getpydanticschema-to-reduce-boilerplate

    A convenience class for creating an annotation that provides pydantic custom type hooks.

    This class is intended to eliminate the need to create a custom "marker" which defines the
     `__get_pydantic_core_schema__` and `__get_pydantic_json_schema__` custom hook methods.

    For example, to have a field treated by type checkers as `int`, but by pydantic as `Any`, you can do:
    ```python
    from typing import Any

    from typing_extensions import Annotated

    from pydantic import BaseModel, GetPydanticSchema

    HandleAsAny = GetPydanticSchema(lambda _s, h: h(Any))

    class Model(BaseModel):
        x: Annotated[int, HandleAsAny]  # pydantic sees `x: Any`

    print(repr(Model(x='abc').x))
    #> 'abc'
    ```
    Nz8Callable[[Any, GetCoreSchemaHandler], CoreSchema] | Noneget_pydantic_core_schemaz=Callable[[Any, GetJsonSchemaHandler], JsonSchemaValue] | Noneget_pydantic_json_schemar   r
   r   c                 C  s8   |dkr| j r| j S |dkr(| jr(| jS t| |S dS )zgUse this rather than defining `__get_pydantic_core_schema__` etc. to reduce the number of nested calls.r   r   N)r  r  object__getattribute__)r|   r   r}   r}   r~   __getattr__  s
    zGetPydanticSchema.__getattr__)r   r   r   r   r  r   r  r	   r  r  r   r}   r}   r}   r~   rl   
  s   
	rl   r   c                   @  s,   e Zd ZU dZded< dddddd	Zd
S )rn   a
  Provides a way to specify the expected tag to use for a case of a (callable) discriminated union.

    Also provides a way to label a union case in error messages.

    When using a callable `Discriminator`, attach a `Tag` to each case in the `Union` to specify the tag that
    should be used to identify that case. For example, in the below example, the `Tag` is used to specify that
    if `get_discriminator_value` returns `'apple'`, the input should be validated as an `ApplePie`, and if it
    returns `'pumpkin'`, the input should be validated as a `PumpkinPie`.

    The primary role of the `Tag` here is to map the return value from the callable `Discriminator` function to
    the appropriate member of the `Union` in question.

    ```python
    from typing import Any, Union

    from typing_extensions import Annotated, Literal

    from pydantic import BaseModel, Discriminator, Tag

    class Pie(BaseModel):
        time_to_cook: int
        num_ingredients: int

    class ApplePie(Pie):
        fruit: Literal['apple'] = 'apple'

    class PumpkinPie(Pie):
        filling: Literal['pumpkin'] = 'pumpkin'

    def get_discriminator_value(v: Any) -> str:
        if isinstance(v, dict):
            return v.get('fruit', v.get('filling'))
        return getattr(v, 'fruit', getattr(v, 'filling', None))

    class ThanksgivingDinner(BaseModel):
        dessert: Annotated[
            Union[
                Annotated[ApplePie, Tag('apple')],
                Annotated[PumpkinPie, Tag('pumpkin')],
            ],
            Discriminator(get_discriminator_value),
        ]

    apple_variation = ThanksgivingDinner.model_validate(
        {'dessert': {'fruit': 'apple', 'time_to_cook': 60, 'num_ingredients': 8}}
    )
    print(repr(apple_variation))
    '''
    ThanksgivingDinner(dessert=ApplePie(time_to_cook=60, num_ingredients=8, fruit='apple'))
    '''

    pumpkin_variation = ThanksgivingDinner.model_validate(
        {
            'dessert': {
                'filling': 'pumpkin',
                'time_to_cook': 40,
                'num_ingredients': 6,
            }
        }
    )
    print(repr(pumpkin_variation))
    '''
    ThanksgivingDinner(dessert=PumpkinPie(time_to_cook=40, num_ingredients=6, filling='pumpkin'))
    '''
    ```

    !!! note
        You must specify a `Tag` for every case in a `Tag` that is associated with a
        callable `Discriminator`. Failing to do so will result in a `PydanticUserError` with code
        [`callable-discriminator-no-tag`](../errors/usage_errors.md#callable-discriminator-no-tag).

    See the [Discriminated Unions] concepts docs for more details on how to use `Tag`s.

    [Discriminated Unions]: ../concepts/unions.md#discriminated-unions
    r   tagr
   r0   r   source_typer   rx   c                 C  s2   ||}| di }t|ts"t| j|tj< |S )Nr5  )
setdefaultr   dictAssertionErrorr  r)   TAGGED_UNION_TAG_KEY)r|   r  r   r   r5  r}   r}   r~   r   w  s
    z Tag.__get_pydantic_core_schema__N)r   r   r   r   r   r   r}   r}   r}   r~   rn   '  s   
Lrn   c                   @  s`   e Zd ZU dZded< dZded< dZded< dZded	< d
dddddZdddddZ	dS )ro   a$
  Usage docs: https://docs.pydantic.dev/2.10/concepts/unions/#discriminated-unions-with-callable-discriminator

    Provides a way to use a custom callable as the way to extract the value of a union discriminator.

    This allows you to get validation behavior like you'd get from `Field(discriminator=<field_name>)`,
    but without needing to have a single shared field across all the union choices. This also makes it
    possible to handle unions of models and primitive types with discriminated-union-style validation errors.
    Finally, this allows you to use a custom callable as the way to identify which member of a union a value
    belongs to, while still seeing all the performance benefits of a discriminated union.

    Consider this example, which is much more performant with the use of `Discriminator` and thus a `TaggedUnion`
    than it would be as a normal `Union`.

    ```python
    from typing import Any, Union

    from typing_extensions import Annotated, Literal

    from pydantic import BaseModel, Discriminator, Tag

    class Pie(BaseModel):
        time_to_cook: int
        num_ingredients: int

    class ApplePie(Pie):
        fruit: Literal['apple'] = 'apple'

    class PumpkinPie(Pie):
        filling: Literal['pumpkin'] = 'pumpkin'

    def get_discriminator_value(v: Any) -> str:
        if isinstance(v, dict):
            return v.get('fruit', v.get('filling'))
        return getattr(v, 'fruit', getattr(v, 'filling', None))

    class ThanksgivingDinner(BaseModel):
        dessert: Annotated[
            Union[
                Annotated[ApplePie, Tag('apple')],
                Annotated[PumpkinPie, Tag('pumpkin')],
            ],
            Discriminator(get_discriminator_value),
        ]

    apple_variation = ThanksgivingDinner.model_validate(
        {'dessert': {'fruit': 'apple', 'time_to_cook': 60, 'num_ingredients': 8}}
    )
    print(repr(apple_variation))
    '''
    ThanksgivingDinner(dessert=ApplePie(time_to_cook=60, num_ingredients=8, fruit='apple'))
    '''

    pumpkin_variation = ThanksgivingDinner.model_validate(
        {
            'dessert': {
                'filling': 'pumpkin',
                'time_to_cook': 40,
                'num_ingredients': 6,
            }
        }
    )
    print(repr(pumpkin_variation))
    '''
    ThanksgivingDinner(dessert=PumpkinPie(time_to_cook=40, num_ingredients=6, filling='pumpkin'))
    '''
    ```

    See the [Discriminated Unions] concepts docs for more details on how to use `Discriminator`s.

    [Discriminated Unions]: ../concepts/unions.md#discriminated-unions
    zstr | Callable[[Any], Hashable]discriminatorNz
str | Noner0  ro  z#dict[str, int | str | float] | Nonecustom_error_contextr
   r0   r   r  c                 C  sv   t |}|rt |s0tt| j d| t| jtr`ddl	m
} |t||| jdf S ||}| |S d S )Nz% must be used with a Union type, not r   )Field)r  )r,   r   Zorigin_is_unionr  r   r   r   r  r   Zpydanticr  r"   _convert_schema)r|   r  r   originr  original_schemar}   r}   r~   r     s    
z*Discriminator.__get_pydantic_core_schema__r   zcore_schema.TaggedUnionSchema)r  rx   c           
      C  s"  |d dkrt |g}i }|d D ]h}d }t|tr>|\}}|d}|d k	rh|tj}|d k	rh|}|d krtd| ddd|||< q$| j}|d kr|d	}| j	}|d kr|d
}| j
}	|	d kr|d}	|d kr|d	n|}t j|| j|||	|d|d|d|dd	S )Nr   unionchoicesr5  z`Tag` not provided for choice z used with `Discriminator`zcallable-discriminator-no-tagr   r0  ro  r  ru   refr   )r0  ro  r  ru   r  r5  r   )r!   r1  r   tupler   r)   r  r3   r0  ro  r  Ztagged_union_schemar  )
r|   r  Ztagged_union_choiceschoicer  r5  Zmetadata_tagr0  ro  r  r}   r}   r~   r    sN    






zDiscriminator._convert_schema)
r   r   r   r   r   r0  ro  r  r   r  r}   r}   r}   r~   ro     s   
Hro   r
   )r  rx   c                 C  sh   t | }|tkr|jS t| tr$dS t| tr2dS t| tr@dS t| trNdS t| tr\dS t	|ddS )Nrv   r   r   listr  r   z<no type name>)
r   _JSON_TYPESr   r   rv   r   r   r  r  r  )r  Ztype_r}   r}   r~   _get_type_name  s    




r  c                   @  s"   e Zd ZeddddddZdS )_AllowAnyJsonr
   r0   r   r  c                 C  s   ||}t jt  |dS )N)r   r  )r!   r  r#  )r   r  r   r  r}   r}   r~   r   2  s    z*_AllowAnyJson.__get_pydantic_core_schema__Nr   r   r   r   r   r}   r}   r}   r~   r  1  s   r  rp   r%   r  r  rt   rv   r   ZNoneTypezinvalid-json-valuez input was not a valid JSON valuern  c                   @  s"   e Zd ZeddddddZdS )_OnErrorOmitr
   r0   r   r  c                 C  s   t j||ddS )NZomit)r   Zon_error)r!   Zwith_default_schema)r   r  r   r}   r}   r~   r     s    z)_OnErrorOmit.__get_pydantic_core_schema__Nr  r}   r}   r}   r~   r    s   r  c                   @  s   e Zd ZU dZdZded< dS )rr   a&  A `FailFast` annotation can be used to specify that validation should stop at the first error.

    This can be useful when you want to validate a large amount of data and you only need to know if it's valid or not.

    You might want to enable this setting if you want to validate your data faster (basically, if you use this,
    validation will be more performant with the caveat that you get less information).

    ```python
    from typing import List

    from typing_extensions import Annotated

    from pydantic import BaseModel, FailFast, ValidationError

    class Model(BaseModel):
        x: Annotated[List[int], FailFast()]

    # This will raise a single error for the first invalid value and stop validation
    try:
        obj = Model(x=[1, 2, 'a', 4, 5, 'b', 7, 8, 9, 'c'])
    except ValidationError as e:
        print(e)
        '''
        1 validation error for Model
        x.2
          Input should be a valid integer, unable to parse string as an integer [type=int_parsing, input_value='a', input_type=str]
        '''
    ```
    Trt   	fail_fastN)r   r   r   r   r  r   r}   r}   r}   r~   rr     s   
rr   )r   Z
__future__r   Z_annotationsr  ZdataclassesZ_dataclassesr  r   r   rz  r   enumr   pathlibr   typesr   typingr	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   Zpydantic_corer   r   r    r!   Ztyping_extensionsr"   r#   r$   r%   r&   r'   Z	_internalr)   r*   r+   r,   r-   r.   Z
_migrationr/   Zannotated_handlersr0   r1   errorsr3   r   r4   warningsr5   __all__rs   Z	dataclassZPydanticMetadatar6   rt   rV   r?   rv   ZGtr@   ZLtrA   ZLerC   ZGerB   rX   rc   rD   r   rE   rF   rH   rG   rY   rI   r9   r   rW   ZGroupedMetadatarm   r=   r   r7   r   r;   r<   r   r:   r   r>   rJ   Z
slots_truer   rK   rL   rM   rN   r   rO   rP   rQ   r8   rR   r   r   r  rS   r'  r(  r)  rT   rU   r:  rZ   r[   r   r\   r]   r`   ra   rb   r^   r_   rd   rg   r  re   rf   rh   ri   rj   rk   r   r  rl   rn   ro   r  r  r   r  r  r  rp   r   r  rq   rr   r}   r}   r}   r~   <module>   s  L  AW Y
8 R  " $b-:**b !8C$
j $%((bbO//W 
	,			