o
    Ú­j¥  ã                   @  sð   U d Z ddlmZ ddlmZmZmZmZ ddlm	Z	m
Z
mZ ddlmZmZ ddlmZ dZdZd	ed
< G dd„ deƒZed Zd	ed< G dd„ deƒZG dd„ deƒZG dd„ deeƒZG dd„ deeƒZdZd	ed< G dd„ deeƒZdS )zš!!! abstract "Usage Documentation"
    [Build a Plugin](../concepts/plugins.md#build-a-plugin)

Plugin interface for Pydantic plugins, and related types.
é    )Úannotations)ÚAnyÚCallableÚLiteralÚ
NamedTuple)Ú
CoreConfigÚ
CoreSchemaÚValidationError)ÚProtocolÚ	TypeAlias)ÚExtraValues)ÚPydanticPluginProtocolÚBaseValidateHandlerProtocolÚValidatePythonHandlerProtocolÚValidateJsonHandlerProtocolÚValidateStringsHandlerProtocolÚNewSchemaReturnsÚSchemaTypePathÚ
SchemaKindúvtuple[ValidatePythonHandlerProtocol | None, ValidateJsonHandlerProtocol | None, ValidateStringsHandlerProtocol | None]r   r   c                   @  s"   e Zd ZU dZded< ded< dS )r   zQPath defining where `schema_type` was defined, or where `TypeAdapter` was called.ÚstrÚmoduleÚnameN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__© r   r   úU/var/www/html/CropPilot/venv/lib/python3.10/site-packages/pydantic/plugin/__init__.pyr      s   
 r   )Ú	BaseModelÚTypeAdapterÚ	dataclassÚcreate_modelÚvalidate_callr   c                   @  s   e Zd ZdZddd„ZdS )r   z5Protocol defining the interface for Pydantic plugins.Úschemar   Úschema_typer   Úschema_type_pathr   Úschema_kindr   ÚconfigúCoreConfig | NoneÚplugin_settingsúdict[str, object]Úreturnr   c                 C  s   t dƒ‚)a�  This method is called for each plugin every time a new [`SchemaValidator`][pydantic_core.SchemaValidator]
        is created.

        It should return an event handler for each of the three validation methods, or `None` if the plugin does not
        implement that method.

        Args:
            schema: The schema to validate against.
            schema_type: The original type which the schema was created from, e.g. the model class.
            schema_type_path: Path defining where `schema_type` was defined, or where `TypeAdapter` was called.
            schema_kind: The kind of schema to validate against.
            config: The config to use for validation.
            plugin_settings: Any plugin settings.

        Returns:
            A tuple of optional event handlers for each of the three validation methods -
                `validate_python`, `validate_json`, `validate_strings`.
        z9Pydantic plugins should implement `new_schema_validator`.)ÚNotImplementedError)Úselfr%   r&   r'   r(   r)   r+   r   r   r   Únew_schema_validator+   s   z+PydanticPluginProtocol.new_schema_validatorN)r%   r   r&   r   r'   r   r(   r   r)   r*   r+   r,   r-   r   )r   r   r   r   r0   r   r   r   r   r   (   s    r   c                   @  s:   e Zd ZU dZded< 	 ddd	„Zddd„Zddd„ZdS )r   z»Base class for plugin callbacks protocols.

    You shouldn't implement this protocol directly, instead use one of the subclasses with adds the correctly
    typed `on_error` method.
    zCallable[..., None]Úon_enterÚresultr   r-   ÚNonec                 C  ó   dS )z{Callback to be notified of successful validation.

        Args:
            result: The result of the validation.
        Nr   )r/   r2   r   r   r   Ú
on_successU   ó   z&BaseValidateHandlerProtocol.on_successÚerrorr	   c                 C  r4   )znCallback to be notified of validation errors.

        Args:
            error: The validation error.
        Nr   )r/   r7   r   r   r   Úon_error]   r6   z$BaseValidateHandlerProtocol.on_errorÚ	exceptionÚ	Exceptionc                 C  r4   )zˆCallback to be notified of validation exceptions.

        Args:
            exception: The exception raised during validation.
        Nr   )r/   r9   r   r   r   Úon_exceptione   r6   z(BaseValidateHandlerProtocol.on_exceptionN)r2   r   r-   r3   )r7   r	   r-   r3   )r9   r:   r-   r3   )r   r   r   r   r   r5   r8   r;   r   r   r   r   r   K   s   
 

r   c                   @  s,   e Zd ZdZddddddddœddd„ZdS )r   z4Event handler for `SchemaValidator.validate_python`.N)ÚstrictÚextraÚfrom_attributesÚcontextÚself_instanceÚby_aliasÚby_nameÚinputr   r<   úbool | Noner=   úExtraValues | Noner>   r?   ú
Any | Noner@   rA   rB   r-   r3   c          	      C  r4   )am  Callback to be notified of validation start, and create an instance of the event handler.

        Args:
            input: The input to be validated.
            strict: Whether to validate the object in strict mode.
            extra: Whether to ignore, allow, or forbid extra data during model validation.
            from_attributes: Whether to validate objects as inputs by extracting attributes.
            context: The context to use for validation, this is passed to functional validators.
            self_instance: An instance of a model to set attributes on from validation, this is used when running
                validation from the `__init__` method of a model.
            by_alias: Whether to use the field's alias to match the input data to an attribute.
            by_name: Whether to use the field's name to match the input data to an attribute.
        Nr   )	r/   rC   r<   r=   r>   r?   r@   rA   rB   r   r   r   r1   q   ó    z&ValidatePythonHandlerProtocol.on_enter)rC   r   r<   rD   r=   rE   r>   rD   r?   rF   r@   rF   rA   rD   rB   rD   r-   r3   ©r   r   r   r   r1   r   r   r   r   r   n   s    ör   c                   @  s*   e Zd ZdZdddddddœddd„ZdS )r   z2Event handler for `SchemaValidator.validate_json`.N)r<   r=   r?   r@   rA   rB   rC   ústr | bytes | bytearrayr<   rD   r=   rE   r?   rF   r@   rA   rB   r-   r3   c                C  r4   )a  Callback to be notified of validation start, and create an instance of the event handler.

        Args:
            input: The JSON data to be validated.
            strict: Whether to validate the object in strict mode.
            extra: Whether to ignore, allow, or forbid extra data during model validation.
            context: The context to use for validation, this is passed to functional validators.
            self_instance: An instance of a model to set attributes on from validation, this is used when running
                validation from the `__init__` method of a model.
            by_alias: Whether to use the field's alias to match the input data to an attribute.
            by_name: Whether to use the field's name to match the input data to an attribute.
        Nr   )r/   rC   r<   r=   r?   r@   rA   rB   r   r   r   r1   �   rG   z$ValidateJsonHandlerProtocol.on_enter)rC   rI   r<   rD   r=   rE   r?   rF   r@   rF   rA   rD   rB   rD   r-   r3   rH   r   r   r   r   r   Œ   s    ÷r   zdict[str, StringInput]ÚStringInputc                   @  s(   e Zd ZdZddddddœddd„ZdS )r   z5Event handler for `SchemaValidator.validate_strings`.N)r<   r=   r?   rA   rB   rC   rJ   r<   rD   r=   rE   r?   rF   rA   rB   r-   r3   c                C  r4   )ab  Callback to be notified of validation start, and create an instance of the event handler.

        Args:
            input: The string data to be validated.
            strict: Whether to validate the object in strict mode.
            extra: Whether to ignore, allow, or forbid extra data during model validation.
            context: The context to use for validation, this is passed to functional validators.
            by_alias: Whether to use the field's alias to match the input data to an attribute.
            by_name: Whether to use the field's name to match the input data to an attribute.
        Nr   )r/   rC   r<   r=   r?   rA   rB   r   r   r   r1   ®   rG   z'ValidateStringsHandlerProtocol.on_enter)rC   rJ   r<   rD   r=   rE   r?   rF   rA   rD   rB   rD   r-   r3   rH   r   r   r   r   r   «   s    ør   N)r   Ú
__future__r   Útypingr   r   r   r   Úpydantic_corer   r   r	   Útyping_extensionsr
   r   Úpydantic.configr   Ú__all__r   r   r   r   r   r   r   r   rJ   r   r   r   r   r   Ú<module>   s     ##