U
    nËj‘  ã                   @  sÊ   d Z ddlmZ ddlZddlmZmZ ddlm	Z	 ddl
mZ dZd	eƒ › d
�Zed ZG dd„ dƒZG dd„ deeƒZG dd„ deeƒZG dd„ deeƒZG dd„ deƒZG dd„ deƒZe	eƒZdS )zPydantic-specific errors.é    )ÚannotationsN)ÚLiteralÚSelfé   )Úgetattr_migration)Úversion_short)ÚPydanticUserErrorÚPydanticUndefinedAnnotationÚPydanticImportErrorÚPydanticSchemaGenerationErrorÚPydanticInvalidForJsonSchemaÚPydanticErrorCodeszhttps://errors.pydantic.dev/z/u/)0zclass-not-fully-definedzcustom-json-schemazdecorator-missing-fieldzdiscriminator-no-fieldzdiscriminator-alias-typezdiscriminator-needs-literalzdiscriminator-aliaszdiscriminator-validatorzcallable-discriminator-no-tagztyped-dict-versionzmodel-field-overriddenzmodel-field-missing-annotationzconfig-bothzremoved-kwargszcircular-reference-schemaúinvalid-for-json-schemazjson-schema-already-usedzbase-model-instantiatedúundefined-annotationúschema-for-unknown-typeúimport-errorzcreate-model-field-definitionszcreate-model-config-basezvalidator-no-fieldszvalidator-invalid-fieldszvalidator-instance-methodzvalidator-input-typezroot-validator-pre-skipz model-serializer-instance-methodzvalidator-field-config-infozvalidator-v1-signaturezvalidator-signaturezfield-serializer-signaturezmodel-serializer-signaturezmultiple-field-serializerszinvalid-annotated-typeztype-adapter-config-unusedzroot-model-extrazunevaluable-type-annotationz dataclass-init-false-extra-allowzclashing-init-and-init-varzmodel-config-invalid-field-namezwith-config-on-modelzdataclass-on-modelzvalidate-call-typezunpack-typed-dictzoverlapping-unpack-typed-dictzinvalid-self-typec                   @  s0   e Zd ZdZddddœdd„Zddœd	d
„ZdS )ÚPydanticErrorMixinzØA mixin class for common functionality shared by all Pydantic-specific errors.

    Attributes:
        message: A message describing the error.
        code: An optional error code from PydanticErrorCodes enum.
    ÚstrzPydanticErrorCodes | NoneÚNone)ÚmessageÚcodeÚreturnc                C  s   || _ || _d S )N©r   r   )Úselfr   r   © r   ú3/tmp/pip-unpacked-wheel-zvl9l234/pydantic/errors.pyÚ__init__U   s    zPydanticErrorMixin.__init__)r   c                 C  s*   | j d kr| jS | j› dt› | j › �S d S )Nz 

For further information visit )r   r   ÚDEV_ERROR_DOCS_URL)r   r   r   r   Ú__str__Y   s    
zPydanticErrorMixin.__str__N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r   M   s   r   c                   @  s   e Zd ZdZdS )r   z1An error raised due to incorrect use of Pydantic.N)r   r    r!   r"   r   r   r   r   r   `   s   r   c                      s>   e Zd ZdZddddœ‡ fdd„Zeddd	œd
d„ƒZ‡  ZS )r	   zÆA subclass of `NameError` raised when handling undefined annotations during `CoreSchema` generation.

    Attributes:
        name: Name of the error.
        message: Description of the error.
    r   r   )Únamer   r   c                   s   || _ tƒ j|dd� d S )Nr   r   )r#   Úsuperr   )r   r#   r   ©Ú	__class__r   r   r   l   s    z$PydanticUndefinedAnnotation.__init__Ú	NameErrorr   )Ú
name_errorr   c                 C  sF   z
|j }W n* tk
r4   t dt|ƒ¡ d¡}Y nX | |t|ƒd�S )zÙConvert a `NameError` to a `PydanticUndefinedAnnotation` error.

        Args:
            name_error: `NameError` to be converted.

        Returns:
            Converted `PydanticUndefinedAnnotation` error.
        z	.*'(.+?)'r   )r#   r   )r#   ÚAttributeErrorÚreÚsearchr   Úgroup)Úclsr(   r#   r   r   r   Úfrom_name_errorp   s
    

z+PydanticUndefinedAnnotation.from_name_error)r   r    r!   r"   r   Úclassmethodr.   Ú__classcell__r   r   r%   r   r	   d   s   r	   c                      s(   e Zd ZdZdddœ‡ fdd„Z‡  ZS )r
   zŽAn error raised when an import fails due to module changes between V1 and V2.

    Attributes:
        message: Description of the error.
    r   r   ©r   r   c                   s   t ƒ j|dd� d S )Nr   ©r   ©r$   r   ©r   r   r%   r   r   r   ˆ   s    zPydanticImportError.__init__©r   r    r!   r"   r   r0   r   r   r%   r   r
   �   s   r
   c                      s(   e Zd ZdZdddœ‡ fdd„Z‡  ZS )r   zŠAn error raised during failures to generate a `CoreSchema` for some type.

    Attributes:
        message: Description of the error.
    r   r   r1   c                   s   t ƒ j|dd� d S )Nr   r2   r3   r4   r%   r   r   r   “   s    z&PydanticSchemaGenerationError.__init__r5   r   r   r%   r   r   Œ   s   r   c                      s(   e Zd ZdZdddœ‡ fdd„Z‡  ZS )r   z‘An error raised during failures to generate a JSON schema for some `CoreSchema`.

    Attributes:
        message: Description of the error.
    r   r   r1   c                   s   t ƒ j|dd� d S )Nr   r2   r3   r4   r%   r   r   r   ž   s    z%PydanticInvalidForJsonSchema.__init__r5   r   r   r%   r   r   —   s   r   )r"   Ú
__future__r   Z_annotationsr*   Ztyping_extensionsr   r   Z
_migrationr   Úversionr   Ú__all__r   r   r   Ú	TypeErrorr   r'   r	   ÚImportErrorr
   r   r   r   Ú__getattr__r   r   r   r   Ú<module>   s"   ÿ4