
    dh                       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e      Zed   Zd	ed<    G d de      Z G d de      Z G d dee      Z G d dee      ZdZd	ed<    G d dee      Zy)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
SchemaKindvtuple[ValidatePythonHandlerProtocol | None, ValidateJsonHandlerProtocol | None, ValidateStringsHandlerProtocol | None]r   r   c                  &    e Zd ZU dZded<   ded<   y)r   zQPath defining where `schema_type` was defined, or where `TypeAdapter` was called.strmodulenameN)__name__
__module____qualname____doc____annotations__     K/var/www/zara/venv/lib/python3.12/site-packages/pydantic/plugin/__init__.pyr   r      s    [K
Ir!   r   )	BaseModelTypeAdapter	dataclasscreate_modelvalidate_callr   c                  4    e Zd ZdZ	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZy)r   z5Protocol defining the interface for Pydantic plugins.c                    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)selfschemaschema_typeschema_type_pathschema_kindconfigplugin_settingss          r"   new_schema_validatorz+PydanticPluginProtocol.new_schema_validator+   s    : ""]^^r!   N)r,   r	   r-   r   r.   r   r/   r   r0   zCoreConfig | Noner1   zdict[str, object]returnr   )r   r   r   r   r2   r    r!   r"   r   r   (   sV    ?__ _ )	_
  _ "_ +_
_r!   r   c                  6    e Zd ZU dZded<   	 ddZd	dZd
dZy)r   zBase 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_enterc                     y)z{Callback to be notified of successful validation.

        Args:
            result: The result of the validation.
        Nr    )r+   results     r"   
on_successz&BaseValidateHandlerProtocol.on_successU        	r!   c                     y)znCallback to be notified of validation errors.

        Args:
            error: The validation error.
        Nr    )r+   errors     r"   on_errorz$BaseValidateHandlerProtocol.on_error]   r9   r!   c                     y)zCallback to be notified of validation exceptions.

        Args:
            exception: The exception raised during validation.
        Nr    )r+   	exceptions     r"   on_exceptionz(BaseValidateHandlerProtocol.on_exceptione   r9   r!   N)r7   r   r3   None)r;   r
   r3   r@   )r>   	Exceptionr3   r@   )r   r   r   r   r   r8   r<   r?   r    r!   r"   r   r   K   s!     "!Er!   r   c                  L    e Zd ZdZdddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZy)r   z4Event handler for `SchemaValidator.validate_python`.N)strictextrafrom_attributescontextself_instanceby_aliasby_namec                    y)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+   inputrC   rD   rE   rF   rG   rH   rI   s	            r"   r5   z&ValidatePythonHandlerProtocol.on_enterq       r!   )rK   r   rC   bool | NonerD   ExtraValues | NonerE   rM   rF   
Any | NonerG   rO   rH   rM   rI   rM   r3   r@   r   r   r   r   r5   r    r!   r"   r   r   n   sy    > #$('+"$( $# 	
 " %  "   
r!   r   c                  F    e Zd ZdZddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZy)r   z2Event handler for `SchemaValidator.validate_json`.N)rC   rD   rF   rG   rH   rI   c                    y)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+   rK   rC   rD   rF   rG   rH   rI   s           r"   r5   z$ValidateJsonHandlerProtocol.on_enter   rL   r!   )rK   zstr | bytes | bytearrayrC   rM   rD   rN   rF   rO   rG   rO   rH   rM   rI   rM   r3   r@   rP   r    r!   r"   r   r      sl    < #$("$( $#& 	
 "  "   
r!   r   zdict[str, StringInput]StringInputc                  @    e Zd ZdZdddddd	 	 	 	 	 	 	 	 	 	 	 	 	 ddZy)r   z5Event handler for `SchemaValidator.validate_strings`.N)rC   rD   rF   rH   rI   c                    y)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+   rK   rC   rD   rF   rH   rI   s          r"   r5   z'ValidateStringsHandlerProtocol.on_enter   rL   r!   )rK   rS   rC   rM   rD   rN   rF   rO   rH   rM   rI   rM   r3   r@   rP   r    r!   r"   r   r      s_    ? #$(" $# 	
 "    
r!   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   rS   r   r    r!   r"   <module>r\      s    # 5 5 A A 1 '	 W )  WZ    hi
I i _X  _F (  F$? <"=x 8 2Y 1%@( r!   