a
    ¡˜ëjÑË  ã                   @  s¤  d Z ddlmZ ddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddlZddlmZ ddlmZmZ ddlmZ ddlmZ ddlmZmZmZ dd	lmZ dd
lmZmZm Z m!Z!m"Z"m#Z# ddl$m%Z% ddl&m'Z'm(Z(m)Z) ddl*m+Z+ ddl,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5 ddl6m7Z7 ej8�rLddl9m:Z: ddœdd„Z;ddœdd„Z<G dd„ deƒZ=G dd„ dƒZ>G dd„ dej?e=d�Z@e@ZAdS )zvThe `Schema <marshmallow.Schema>` class, including its metaclass and options (`class Meta <marshmallow.Schema.Meta>`).é    )ÚannotationsN)ÚABCMeta)ÚOrderedDictÚdefaultdict)ÚMapping)Úzip_longest)ÚbaseÚclass_registryÚtypes)Úfields)Ú	POST_DUMPÚ	POST_LOADÚPRE_DUMPÚPRE_LOADÚ	VALIDATESÚVALIDATES_SCHEMA)Ú
ErrorStore)ÚSCHEMAÚStringNotCollectionErrorÚValidationError)Ú
OrderedSet)	ÚEXCLUDEÚINCLUDEÚRAISEÚ	get_valueÚis_collectionÚis_instance_or_subclassÚmissingÚ	set_valueÚ validate_unknown_parameter_value)ÚRemovedInMarshmallow4Warning)ÚFieldúlist[tuple[str, Field]]©Úreturnc                 C  s   dd„ |   ¡ D ƒS )zKGet fields from a class

    :param attrs: Mapping of class attributes
    c                 S  s$   g | ]\}}t |tjƒr||f‘qS © )r   r   ÚFieldABC)Ú.0Ú
field_nameZfield_valuer%   r%   úQ/mnt/bigstor/www/usecases/.venv/lib/python3.9/site-packages/marshmallow/schema.pyÚ
<listcomp>7   s   þz_get_fields.<locals>.<listcomp>)Úitems)Úattrsr%   r%   r)   Ú_get_fields2   s    þr-   Ú
SchemaMeta)Úklassc                 C  s.   t  | ¡}t tjdd„ |ddd… D ƒg ¡S )a  Collect fields from a class, following its method resolution order. The
    class itself is excluded from the search; only its parents are checked. Get
    fields from ``_declared_fields`` if available, else use ``__dict__``.

    :param klass: Class whose fields to retrieve
    c                 s  s    | ]}t t|d |jƒƒV  qdS )Ú_declared_fieldsN)r-   ÚgetattrÚ__dict__)r'   r   r%   r%   r)   Ú	<genexpr>M   s   ýÿz%_get_fields_by_mro.<locals>.<genexpr>Nr   éÿÿÿÿ)ÚinspectÚgetmroÚ	functoolsÚreduceÚoperatorÚiadd)r/   Úmror%   r%   r)   Ú_get_fields_by_mro@   s    
üør<   c                      s†   e Zd ZU dZded< ded< ded< ded< d	d
dd dœ‡ fdd„Zeefd dddddœdd„ƒZ‡ fdd„Z	ddœdd„Z
‡  ZS )r.   a#  Metaclass for the Schema class. Binds the declared fields to
    a ``_declared_fields`` attribute, which is a dictionary mapping attribute
    names to field objects. Also sets the ``opts`` class attribute, which is
    the Schema class's `class Meta <marshmallow.Schema.Meta>` options.
    ÚtypeÚMetaú
typing.AnyÚoptsÚOPTIONS_CLASSúdict[str, Field]r0   Ústrztuple[type, ...]zdict[str, typing.Any])ÚnameÚbasesr,   r$   c                   sÂ   |  d¡}t|ddƒ}|sJ|D ]&}t|dƒrt|jdƒr|jj} qJqd}t|ƒ}|D ]\}}	||= qVtƒ  | |||¡}
t|
ƒ}|
j}|
j	||d�|
_
|t|
j
j ¡ ƒ7 }| j|
||td�|
_|
S )Nr>   ÚorderedF)rF   )r/   Ú
cls_fieldsÚinherited_fieldsÚdict_cls)Úgetr1   Úhasattrr>   rF   r-   ÚsuperÚ__new__r<   rA   r@   ÚlistÚincluder+   Úget_declared_fieldsÚdictr0   )ÚmcsrD   rE   r,   ÚmetarF   Zbase_rG   r(   Ú_r/   rH   ©Ú	__class__r%   r)   rM   c   s.    
üzSchemaMeta.__new__r"   ú
type[dict])r/   rG   rH   rI   r$   c                 C  s   ||| ƒS )aA  Returns a dictionary of field_name => `Field` pairs declared on the class.
        This is exposed mainly so that plugins can add additional fields, e.g. fields
        computed from `class Meta <marshmallow.Schema.Meta>` options.

        :param klass: The class object.
        :param cls_fields: The fields declared on the class, including those added
            by the ``include`` `class Meta <marshmallow.Schema.Meta>` option.
        :param inherited_fields: Inherited fields.
        :param dict_cls: dict-like class to use for dict output Default to ``dict``.
        r%   )rR   r/   rG   rH   rI   r%   r%   r)   rP   Ž   s    zSchemaMeta.get_declared_fieldsc                   s6   t ƒ  |||¡ |r(| jjr(t || ¡ |  ¡ | _d S ©N)rL   Ú__init__r@   Úregisterr	   Úresolve_hooksÚ_hooks)ÚclsrD   rE   r,   rU   r%   r)   rY   ¢   s    zSchemaMeta.__init__ú'dict[str, list[tuple[str, bool, dict]]]r#   c              
     s¦   t  | ¡}ttƒ}t| ƒD ]†‰ |D ].}z|jˆ  }W n tyJ   Y q"Y q"0  qTq"qz
|j}W n typ   Y q0 | 	¡ D ]$\}}||  
‡ fdd„|D ƒ¡ qzq|S )z—Add in the decorated processors

        By doing this after constructing the class, we let standard inheritance
        do all the hard work.
        c                 3  s   | ]\}}ˆ ||fV  qd S rX   r%   )r'   ÚmanyÚkwargs©Ú	attr_namer%   r)   r3   Í   s   z+SchemaMeta.resolve_hooks.<locals>.<genexpr>)r5   r6   r   rN   Údirr2   ÚKeyErrorZ__marshmallow_hook__ÚAttributeErrorr+   Úextend)r]   r;   ÚhooksÚparentÚattrZhook_configÚtagÚconfigr%   ra   r)   r[   ¨   s(    

ÿÿzSchemaMeta.resolve_hooks)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__rM   ÚclassmethodrQ   rP   rY   r[   Ú__classcell__r%   r%   rU   r)   r.   W   s   
+ûc                   @  s"   e Zd ZdZd	dddœdd„ZdS )
Ú
SchemaOptsz/Defines defaults for `marshmallow.Schema.Meta`.Fr=   Úbool)rS   rF   c                 C  s~  t |ddƒ| _t| jttfƒs&tdƒ‚t |ddƒ| _t| jttfƒsLtdƒ‚| jr`| jr`tdƒ‚t |ddƒ| _t| jttfƒs†tdƒ‚t |d	d ƒ| _t |d
d ƒ| _	t |dd ƒ| _
t|dƒrØtjdtdd� t |dtƒ}nt}t |d|ƒ| _t|dƒ�rtjdtdd� t |d|ƒ| _t |ddƒ| _t |di ƒ| _t |ddƒ| _t |ddƒ| _tt |dtƒƒ| _t |ddƒ| _t |ddƒ| _d S )Nr   r%   z(`fields` option must be a list or tuple.Ú
additionalz,`additional` option must be a list or tuple.zFCannot set both `fields` and `additional` options for the same Schema.Úexcludez"`exclude` must be a list or tuple.Ú
dateformatÚdatetimeformatÚ
timeformatZjson_modulezKThe json_module class Meta option is deprecated. Use render_module instead.é   ©Ú
stacklevelÚrender_modulerF   z§The `ordered` `class Meta` option is deprecated. Field order is already preserved by default. Set `Schema.dict_class` to OrderedDict to maintain the previous behavior.Úindex_errorsTrO   Ú	load_onlyÚ	dump_onlyÚunknownrZ   r_   F)r1   r   Ú
isinstancerN   ÚtupleÚ
ValueErrorru   rv   rw   rx   ry   rK   ÚwarningsÚwarnr    Újsonr}   rF   r~   rO   r   r€   r   r   r�   rZ   r_   )ÚselfrS   rF   r}   r%   r%   r)   rY   ×   sN    ÿ
ýûzSchemaOpts.__init__N)F)rl   rm   rn   ro   rY   r%   r%   r%   r)   rs   Ô   s   rs   c                   @  s0  e Zd ZU dZeejeejej	ej
eejeejeejeejeejeejejejejejejejejejejejiZde d< i Z!de d< dddœZ"de d	< e#Z$d
e d< e%Z&de d< i Z'de d< i Z(de d< G dd„ dƒZ)dddddddddœdddddddddœdd„Z*dd œd!d"„Z+e,d#d œd$d%„ƒZ-e.d&d'œddd(d)œd*d+„ƒZ/d,dd-d.œd/d0„Z0dddd1œd2d3„Z1e2dd4œd5d6„ƒZ3d7d8œdd-d9œd:d;„Z4dd8œddd9œd<d=„Z5dd8œddd9œd>d?„Z6d7de7dd@œdAdBd-dCdDœdEdF„Z8ddddGœdAddddHœdIdJ„Z9ddddGœdKddddLœdMdN„Z:dd4œdOdBd-dd-dPdQœdRdS„Z;dddTœdAdddUdVœdWdX„Z<ddddYdZœdAdddd-d[œd\d]„Z=d^d œd_d`„Z>d^d œdadb„Z?d^d œdcdd„Z@dded^dfœdgdh„ZAdded^dfœdidj„ZBddkœdd-dlœdmdn„ZCdd-ddoœdpdq„ZDdBd-drœdsdt„ZEd7duœdBd-d-dd-dvœdwdx„ZFddkœdd-d-dyœdzd{„ZGdS )|ÚSchemaa±  Base schema class with which to define schemas.

    Example usage:

    .. code-block:: python

        import datetime as dt
        from dataclasses import dataclass

        from marshmallow import Schema, fields


        @dataclass
        class Album:
            title: str
            release_date: dt.date


        class AlbumSchema(Schema):
            title = fields.Str()
            release_date = fields.Date()


        album = Album("Beggars Banquet", dt.date(1968, 12, 6))
        schema = AlbumSchema()
        data = schema.dump(album)
        data  # {'release_date': '1968-12-06', 'title': 'Beggars Banquet'}

    :param only: Whitelist of the declared fields to select when
        instantiating the Schema. If None, all fields are used. Nested fields
        can be represented with dot delimiters.
    :param exclude: Blacklist of the declared fields to exclude
        when instantiating the Schema. If a field appears in both `only` and
        `exclude`, it is not used. Nested fields can be represented with dot
        delimiters.
    :param many: Should be set to `True` if ``obj`` is a collection
        so that the object will be serialized to a list.
    :param context: Optional context passed to :class:`fields.Method` and
        :class:`fields.Function` fields.
    :param load_only: Fields to skip during serialization (write-only fields)
    :param dump_only: Fields to skip during deserialization (read-only fields)
    :param partial: Whether to ignore missing fields and not require
        any fields declared. Propagates down to ``Nested`` fields as well. If
        its value is an iterable, only missing fields listed in that iterable
        will be ignored. Use dot delimiters to specify nested fields.
    :param unknown: Whether to exclude, include, or raise an error for unknown
        fields in the data. Use `EXCLUDE`, `INCLUDE` or `RAISE`.

    .. versionchanged:: 3.0.0
        `prefix` parameter removed.
    zdict[type, type[Field]]ÚTYPE_MAPPINGzdict[str, str]Úerror_messageszInvalid input type.zUnknown field.)r=   r�   Ú_default_error_messagesr=   rA   r?   r@   rB   r0   r^   r\   c                   @  sŠ   e Zd ZU dZded< ded< ded< ded< ded	< d
ed< d
ed< d
ed< ded< ded< ded< ded< ded< d
ed< ded< dS )zSchema.Metaa)  Options object for a Schema.

        Example usage: ::

            from marshmallow import Schema


            class MySchema(Schema):
                class Meta:
                    fields = ("id", "email", "date_created")
                    exclude = ("password", "secret_attribute")

        .. admonition:: A note on type checking

            Type checkers will only check the attributes of the `Meta <marshmallow.Schema.Meta>`
            class if you explicitly subclass `marshmallow.Schema.Meta`.

            .. code-block:: python

                from marshmallow import Schema


                class MySchema(Schema):
                    # Not checked by type checkers
                    class Meta:
                        additional = True


                class MySchema2(Schema):
                    # Type checkers will check attributes
                    class Meta(Schema.Meta):
                        additional = True  # Incompatible types in assignment

        .. versionremoved:: 3.0.0b7 Remove ``strict``.
        .. versionadded:: 3.0.0b12 Add `unknown`.
        .. versionchanged:: 3.0.0b17 Rename ``dateformat`` to `datetimeformat`.
        .. versionadded:: 3.9.0 Add `timeformat`.
        .. versionchanged:: 3.26.0 Deprecate `ordered`. Field order is preserved by default.
        z,typing.ClassVar[tuple[str, ...] | list[str]]r   ru   z!typing.ClassVar[dict[str, Field]]rO   rv   ztyping.ClassVar[bool]r_   ztyping.ClassVar[str]rw   rx   ry   r?   r}   rF   r~   r   r€   r�   rZ   N)rl   rm   rn   ro   rp   r%   r%   r%   r)   r>   Z  s"   
(r>   Nr%   )Úonlyrv   r_   Úcontextr   r€   Úpartialr�   ztypes.StrSequenceOrSet | Noneztypes.StrSequenceOrSetzbool | Nonezdict | Nonez$bool | types.StrSequenceOrSet | Nonez
str | Nonec                C  sP  |d urt |ƒstdƒ‚t |ƒs(tdƒ‚t | j¡| _|d u rF| jjn|| _|| _t	| jj
ƒt	|ƒB | _
| jj| _t	|ƒp„t	| jjƒ| _t	|ƒpšt	| jjƒ| _|| _|d u r´| jjnt|ƒ| _|rÒtjdtdd� |pØi | _|  ¡  i | _i | _i | _|  ¡  i }	|	 | j¡ t| jjƒD ]}
|	 t|
di ƒ¡ �q|	 | j �pBi ¡ |	| _ d S )Nz""only" should be a list of stringsz%"exclude" should be a list of stringszƒThe `context` parameter is deprecated and will be removed in marshmallow 4.0. Use `contextvars.ContextVar` to pass context instead.rz   r{   r‹   )!r   r   ÚcopyÚdeepcopyr0   Údeclared_fieldsr@   r_   r�   Úsetrv   rF   r   r€   r�   r�   r   r…   r†   r    rŽ   Ú_normalize_nested_optionsr   Úload_fieldsÚdump_fieldsÚ_init_fieldsÚupdaterŒ   ÚreversedrV   Ú__mro__r1   r‹   )rˆ   r�   rv   r_   rŽ   r   r€   r�   r�   Úmessagesr]   r%   r%   r)   rY   µ  sL    ÿþ
ÿ
ýü
zSchema.__init__rC   r#   c                 C  s   d| j j› d| j› d�S )Nú<z(many=z)>)rV   rl   r_   ©rˆ   r%   r%   r)   Ú__repr__ë  s    zSchema.__repr__rW   c                 C  s   | j r
tS tS )z'`dict` type to return when serializing.)rF   r   rQ   r�   r%   r%   r)   Ú
dict_classî  s    zSchema.dict_classZGeneratedSchema)rD   ztype[Schema])r   rD   r$   c                C  s8   t dt| dtƒfddiƒ}t || fi | ¡ ¥d|i¥ƒS )a£  Generate a `Schema <marshmallow.Schema>` class given a dictionary of fields.

        .. code-block:: python

            from marshmallow import Schema, fields

            PersonSchema = Schema.from_dict({"name": fields.Str()})
            print(PersonSchema().load({"name": "David"}))  # => {'name': 'David'}

        Generated schemas are not added to the class registry and therefore cannot
        be referred to by name in `Nested` fields.


        :param fields: Dictionary mapping field names to field instances.
        :param name: Optional name for the class, which will appear in
            the ``repr`` for the class.

        .. versionadded:: 3.0.0
        ZGeneratedMetar>   rZ   F)r=   r1   Úobjectr�   )r]   r   rD   r>   r%   r%   r)   Ú	from_dictõ  s    ÿzSchema.from_dictr   rt   )ÚerrorÚdatar_   c                K  s   dS )a›  Custom error handler function for the schema.

        :param error: The `ValidationError` raised during (de)serialization.
        :param data: The original input data.
        :param many: Value of ``many`` on dump or load.
        :param partial: Value of ``partial`` on load.

        .. versionchanged:: 3.0.0rc9
            Receives `many` and `partial` (on deserialization) as keyword arguments.
        Nr%   )rˆ   r¢   r£   r_   r`   r%   r%   r)   Úhandle_error  s    zSchema.handle_error)Úobjri   Údefaultc                 C  s   t |||ƒS )z›Defines how to pull values from an object to serialize.

        .. versionchanged:: 3.0.0a1
            Changed position of ``obj`` and ``attr``.
        )r   )rˆ   r¥   ri   r¦   r%   r%   r)   Úget_attribute$  s    zSchema.get_attribute©Úindexc             
   C  sR   z| |ƒ}W n@ t yL } z(|j|j||d� |jp6tW  Y d}~S d}~0 0 |S )a   Call ``getter_func`` with ``data`` as its argument, and store any `ValidationErrors`.

        :param getter_func: Function for getting the serialized/deserialized
            value from ``data``.
        :param data: The data passed to ``getter_func``.
        :param field_name: Field name.
        :param index: Index of the item being validated, if validating a collection,
            otherwise `None`.
        r¨   N)r   Ústore_errorr›   Ú
valid_datar   )Úgetter_funcr£   r(   Úerror_storer©   Úvaluer¢   r%   r%   r)   Ú_call_and_store.  s     zSchema._call_and_storeF©r_   )r¥   r_   c                  sv   |r|dur‡ fdd„|D ƒS ˆ   ¡ }ˆ j ¡ D ]@\}}|j||ˆ jd�}|tu rTq0|jdurd|jn|}|||< q0|S )zÏSerialize ``obj``.

        :param obj: The object(s) to serialize.
        :param many: `True` if ``data`` should be serialized as a collection.
        :return: A dictionary of the serialized data
        Nc                   s   g | ]}ˆ j |d d�‘qS )Fr°   )Ú
_serialize)r'   Údr�   r%   r)   r*   J  ó    z%Schema._serialize.<locals>.<listcomp>)Úaccessor)rŸ   r–   r+   Ú	serializer§   r   Údata_key)rˆ   r¥   r_   Úretrb   Ú	field_objr®   Úkeyr%   r�   r)   r±   B  s    
zSchema._serializec                C  sf   |du r| j nt|ƒ}| jt r4| jt|||d�}n|}| j||d�}| jt rb| jt|||d�}|S )aª  Serialize an object to native Python data types according to this
        Schema's fields.

        :param obj: The object to serialize.
        :param many: Whether to serialize `obj` as a collection. If `None`, the value
            for `self.many` is used.
        :return: Serialized data

        .. versionadded:: 1.0.0
        .. versionchanged:: 3.0.0b7
            This method returns the serialized data rather than a ``(data, errors)`` duple.
            A :exc:`ValidationError <marshmallow.exceptions.ValidationError>` is raised
            if ``obj`` is invalid.
        .. versionchanged:: 3.0.0rc9
            Validation no longer occurs upon serialization.
        N)r_   Úoriginal_datar°   )r_   rt   r\   r   Ú_invoke_dump_processorsr±   r   )rˆ   r¥   r_   Zprocessed_objÚresultr%   r%   r)   ÚdumpT  s    
ÿ
ÿzSchema.dumpc                O  s*   | j ||d�}| jjj|g|¢R i |¤ŽS )a+  Same as :meth:`dump`, except return a JSON-encoded string.

        :param obj: The object to serialize.
        :param many: Whether to serialize `obj` as a collection. If `None`, the value
            for `self.many` is used.
        :return: A ``json`` string

        .. versionadded:: 1.0.0
        .. versionchanged:: 3.0.0b7
            This method returns the serialized data rather than a ``(data, errors)`` duple.
            A :exc:`ValidationError <marshmallow.exceptions.ValidationError>` is raised
            if ``obj`` is invalid.
        r°   )r½   r@   r}   Údumps)rˆ   r¥   r_   Úargsr`   Z
serializedr%   r%   r)   r¾   v  s    zSchema.dumps)r_   r�   r�   r©   zRtyping.Mapping[str, typing.Any] | typing.Iterable[typing.Mapping[str, typing.Any]]r   ztyping.Any | list[typing.Any])r£   r­   r_   r$   c                  sð  ˆj j}|r|nd}|r\tˆ ƒs<ˆjˆjd g|d� g }n‡‡‡‡fdd„tˆ ƒD ƒ}|S ˆ ¡ }	tˆ tƒsˆˆjˆjd g|d� �ndtˆƒ}
ˆj	 
¡ D ]Ø\}}|jdur²|jn|}ˆ  |t¡}|tu ràˆdu sš|
rà|ˆv ràqši }|
�r|d ‰tˆƒ‰‡‡fdd„ˆD ƒ}||d	< nˆdu�r*ˆ|d	< |||f‡ fd
d„	}ˆj|||ˆ|d�}|turš|j�pd|}t|	||ƒ qšˆtk�rìdd„ ˆj	 
¡ D ƒ}tˆ ƒ| D ]L}ˆ | }ˆtk�r¾||	|< n*ˆtk�ržˆ ˆjd g||�râ|nd¡ �qž|	S )a«  Deserialize ``data``.

        :param data: The data to deserialize.
        :param error_store: Structure to store errors.
        :param many: `True` if ``data`` should be deserialized as a collection.
        :param partial: Whether to ignore missing fields and not require
            any fields declared. Propagates down to ``Nested`` fields as well. If
            its value is an iterable, only missing fields listed in that iterable
            will be ignored. Use dot delimiters to specify nested fields.
        :param unknown: Whether to exclude, include, or raise an error for unknown
            fields in the data. Use `EXCLUDE`, `INCLUDE` or `RAISE`.
        :param index: Index of the item being serialized (for storing errors) if
            serializing a collection, otherwise `None`.
        :return: The deserialized data as `dict_class` instance or list of `dict_class`
        instances if `many` is `True`.
        Nr=   r¨   c              
     s.   g | ]&\}}ˆj t t|¡ˆ d ˆˆ|d�‘qS )F)r­   r_   r�   r�   r©   )Ú_deserializeÚtypingÚcastrQ   )r'   Úidxr²   )r­   r�   rˆ   r�   r%   r)   r*   «  s   	ø
úz'Schema._deserialize.<locals>.<listcomp>TÚ.c                   s"   g | ]}|  ˆ¡r|ˆ d … ‘qS rX   )Ú
startswith)r'   Úf)Ú
len_prefixÚprefixr%   r)   r*   Í  s   r�   c                   s   |j | |ˆ fi |¤ŽS rX   )Zdeserialize)Úvalr¸   r(   Úd_kwargs)r£   r%   r)   ÚgetterÔ  s    ýüz#Schema._deserialize.<locals>.getter©r¬   r£   r(   r­   r©   c                 S  s$   h | ]\}}|j d ur|j n|’qS rX   ©r¶   )r'   r(   r¸   r%   r%   r)   Ú	<setcomp>é  s   ÿz&Schema._deserialize.<locals>.<setcomp>r�   )r@   r~   r   rª   r‹   Ú	enumeraterŸ   r‚   r   r•   r+   r¶   rJ   r   Úlenr¯   Ú	attributer   r   r“   r   r   )rˆ   r£   r­   r_   r�   r�   r©   r~   Zret_lZret_dZpartial_is_collectionrb   r¸   r(   Z	raw_valuerÊ   Zsub_partialrË   r®   r¹   r   r%   )r£   r­   rÇ   r�   rÈ   rˆ   r�   r)   rÀ   ‡  s|    	÷
ÿÿÿÿ

ÿ
û
þ



ýzSchema._deserialize©r_   r�   r�   )r£   r_   r�   r�   c                C  s   | j ||||dd�S )aR  Deserialize a data structure to an object defined by this Schema's fields.

        :param data: The data to deserialize.
        :param many: Whether to deserialize `data` as a collection. If `None`, the
            value for `self.many` is used.
        :param partial: Whether to ignore missing fields and not require
            any fields declared. Propagates down to ``Nested`` fields as well. If
            its value is an iterable, only missing fields listed in that iterable
            will be ignored. Use dot delimiters to specify nested fields.
        :param unknown: Whether to exclude, include, or raise an error for unknown
            fields in the data. Use `EXCLUDE`, `INCLUDE` or `RAISE`.
            If `None`, the value for `self.unknown` is used.
        :return: Deserialized data

        .. versionadded:: 1.0.0
        .. versionchanged:: 3.0.0b7
            This method returns the deserialized data rather than a ``(data, errors)`` duple.
            A :exc:`ValidationError <marshmallow.exceptions.ValidationError>` is raised
            if invalid data are passed.
        T©r_   r�   r�   Úpostprocess)Ú_do_load)rˆ   r£   r_   r�   r�   r%   r%   r)   Úloadù  s    
ÿzSchema.loadzstr | bytes | bytearray)Ú	json_datar_   r�   r�   c                K  s(   | j jj|fi |¤Ž}| j||||d�S )a²  Same as :meth:`load`, except it uses `marshmallow.Schema.Meta.render_module` to deserialize
        the passed string before passing data to :meth:`load`.

        :param json_data: A string of the data to deserialize.
        :param many: Whether to deserialize `obj` as a collection. If `None`, the
            value for `self.many` is used.
        :param partial: Whether to ignore missing fields and not require
            any fields declared. Propagates down to ``Nested`` fields as well. If
            its value is an iterable, only missing fields listed in that iterable
            will be ignored. Use dot delimiters to specify nested fields.
        :param unknown: Whether to exclude, include, or raise an error for unknown
            fields in the data. Use `EXCLUDE`, `INCLUDE` or `RAISE`.
            If `None`, the value for `self.unknown` is used.
        :return: Deserialized data

        .. versionadded:: 1.0.0
        .. versionchanged:: 3.0.0b7
            This method returns the deserialized data rather than a ``(data, errors)`` duple.
            A :exc:`ValidationError <marshmallow.exceptions.ValidationError>` is raised
            if invalid data are passed.
        rÒ   )r@   r}   ÚloadsrÖ   )rˆ   r×   r_   r�   r�   r`   r£   r%   r%   r)   rØ     s    zSchema.loadsztypes.SchemaValidatorz
int | None)Úvalidator_funcr­   r_   r�   Úpass_originalr©   c                C  sÐ   z(|r|||||d� n||||d� W n¢ t yÊ }	 zŠ|	j}
|
tkrLt}nXd }z| j|
 }W n& ty„   |
| jv r€| j|
 }Y n0 |r |jd urš|jn|
}n|
}|j|	j||d� W Y d }	~	n
d }	~	0 0 d S )N)r�   r_   r¨   )	r   r(   r   r   rd   r’   r¶   rª   r›   )rˆ   rÙ   Úoutputrº   r­   r_   r�   rÚ   r©   Úerrr(   r¶   r¸   r%   r%   r)   Ú_run_validator=  s*    
ÿýzSchema._run_validator©r_   r�   zdict[str, list[str]])r£   r_   r�   r$   c             
   C  sZ   z| j |||dd� W n> tyT } z&t tttt f |j¡W  Y d}~S d}~0 0 i S )a”  Validate `data` against the schema, returning a dictionary of
        validation errors.

        :param data: The data to validate.
        :param many: Whether to validate `data` as a collection. If `None`, the
            value for `self.many` is used.
        :param partial: Whether to ignore missing fields and not require
            any fields declared. Propagates down to ``Nested`` fields as well. If
            its value is an iterable, only missing fields listed in that iterable
            will be ignored. Use dot delimiters to specify nested fields.
        :return: A dictionary of validation errors.

        .. versionadded:: 1.1.0
        F)r_   r�   rÔ   N)rÕ   r   rÁ   rÂ   rQ   rC   rN   r›   )rˆ   r£   r_   r�   Úexcr%   r%   r)   Úvalidated  s
    0zSchema.validateTrÓ   )r£   r_   r�   r�   rÔ   c             
   C  s¢  t ƒ }i }|du r| jnt|ƒ}|du r.| jnt|ƒ}|du rD| j}| jt ršz| jt||||d�}W qž t	y– }	 z|	 
¡ }d}
W Y d}	~	qžd}	~	0 0 n|}|�st| j|||||d�}
| j||
|d� | jt �rt|jƒ}| j|d|
||||d� | j|d|
||||d� |j}|�st|�rt| jt �rtz| jt|
|||d�}
W n. t	�yr }	 z|	 
¡ }W Y d}	~	n
d}	~	0 0 |�ržt	|||
d�}| j||||d	� |‚|
S )
ar  Deserialize `data`, returning the deserialized result.
        This method is private API.

        :param data: The data to deserialize.
        :param many: Whether to deserialize `data` as a collection. If `None`, the
            value for `self.many` is used.
        :param partial: Whether to validate required fields. If its
            value is an iterable, only fields listed in that iterable will be
            ignored will be allowed missing. If `True`, all fields will be allowed missing.
            If `None`, the value for `self.partial` is used.
        :param unknown: Whether to exclude, include, or raise an error for unknown
            fields in the data. Use `EXCLUDE`, `INCLUDE` or `RAISE`.
            If `None`, the value for `self.unknown` is used.
        :param postprocess: Whether to run post_load methods..
        :return: Deserialized data
        N)r_   rº   r�   )r­   r_   r�   r�   )r­   r£   r_   T)r­   Ú	pass_manyr£   rº   r_   r�   Úfield_errorsF)r£   r«   rÞ   )r   r_   rt   r�   r   r�   r\   r   Ú_invoke_load_processorsr   Znormalized_messagesrÀ   Ú_invoke_field_validatorsr   ÚerrorsÚ_invoke_schema_validatorsr   r¤   )rˆ   r£   r_   r�   r�   rÔ   r­   rå   Zprocessed_datarÜ   r¼   râ   rß   r%   r%   r)   rÕ   „  s„    ÿý

ÿ
ûÿ
ù	ù	û
zSchema._do_loadÚNonec                 C  sd   | j dur2|  d| j d¡ |  dd„ | j D ƒ¡| _ | jr`|  d| jd¡ |  dd„ | jD ƒ¡| _dS )	zVApply then flatten nested schema options.
        This method is private API.
        Nr�   Úintersectionc                 S  s   g | ]}|  d d¡d ‘qS )rÄ   é   r   ©Úsplit©r'   Úfieldr%   r%   r)   r*   ó  r³   z4Schema._normalize_nested_options.<locals>.<listcomp>rv   Úunionc                 S  s   g | ]}d |vr|‘qS )rÄ   r%   rì   r%   r%   r)   r*   ù  r³   )r�   Ú_Schema__apply_nested_optionÚ	set_classrv   r�   r%   r%   r)   r”   ë  s    
ÿz Schema._normalize_nested_optionsc                 C  sª   dd„ |D ƒ}t tƒ}|D ]\}}||  |¡ qt| ¡ ƒD ]f\}}	|  |	¡}
t| j| |dƒ}|r’|dkr||
|  |¡O }
|dkr’|
|  |¡M }
t| j| ||
ƒ q>dS )z%Apply nested options to nested fieldsc                 S  s    g | ]}d |v r|  d d¡‘qS )rÄ   ré   rê   )r'   rD   r%   r%   r)   r*   ÿ  r³   z0Schema.__apply_nested_option.<locals>.<listcomp>r%   rî   rè   N)	r   rN   ÚappendÚiterr+   rð   r1   r’   Úsetattr)rˆ   Zoption_nameÚfield_namesZset_operationZnested_fieldsZnested_optionsrh   Znested_namesr¹   ÚoptionsÚnew_optionsZoriginal_optionsr%   r%   r)   Z__apply_nested_optionü  s    
zSchema.__apply_nested_optionc                   sÚ  | j jr|  | j j¡}n*|  | j ¡ ¡}| j jrB||  | j j¡O }|  ¡ }| jdurn|  | j¡}||| O }n|}| jr�|| j }|| j| O }|r®d| › d|› d�}t|ƒ‚|  	¡ }|D ]*}| j 
|t ¡ ¡}|  ||¡ |||< qº|  	¡ |  	¡  }}	| ¡ D ]*\}}|j�s|||< |j�s ||	|< �q dd„ |	 ¡ D ƒ‰ tˆ ƒttˆ ƒƒk�rx‡ fdd„ˆ D ƒ}
td	t|
ƒ› �ƒ‚d
d„ | ¡ D ƒ‰tˆƒttˆƒƒk�rÄ‡fdd„ˆD ƒ}tdt|ƒ› �ƒ‚|| _|	| _|| _dS )z€Update self.fields, self.load_fields, and self.dump_fields based on schema options.
        This method is private API.
        NzInvalid fields for z: rÄ   c                 S  s$   g | ]\}}|j d ur|j n|‘qS rX   rÍ   )r'   rD   r¸   r%   r%   r)   r*   <  s   ÿz'Schema._init_fields.<locals>.<listcomp>c                   s   h | ]}ˆ   |¡d kr|’qS ©ré   ©Úcount©r'   Úx)Údump_data_keysr%   r)   rÎ   A  s   z&Schema._init_fields.<locals>.<setcomp>zžThe data_key argument for one or more fields collides with another field's name or data_key argument. Check the following field names and data_key arguments: c                 S  s   g | ]\}}|j p|‘qS r%   )rÑ   )r'   rD   r¥   r%   r%   r)   r*   J  r³   c                   s   h | ]}ˆ   |¡d kr|’qS r÷   rø   rú   )Úload_attributesr%   r)   rÎ   L  s   z¡The attribute argument for one or more fields collides with another field's name or attribute argument. Check the following field names and attribute arguments: )r@   r   rð   r’   Úkeysru   r�   rv   r„   rŸ   rJ   Ú	ma_fieldsZInferredÚ_bind_fieldr+   r€   r   rÐ   r“   rN   r–   r•   )rˆ   Zavailable_field_namesZinvalid_fieldsrô   ÚmessageZfields_dictr(   r¸   r•   r–   Zdata_keys_duplicatesZattributes_duplicatesr%   )rü   rý   r)   r—     sh    


þ
ÿýÿ
ÿýÿzSchema._init_fieldsr!   )r(   r¸   r$   c                 C  s   dS )zqHook to modify a field when it is bound to the `Schema <marshmallow.Schema>`.

        No-op by default.
        Nr%   )rˆ   r(   r¸   r%   r%   r)   Úon_bind_fieldZ  s    zSchema.on_bind_fieldc              
   C  sœ   || j v rd|_ || jv r d|_z| || ¡ W nZ tyŠ } zBt|tƒrtt|tjƒrtd|› d|j	› d�}t|ƒ|‚‚ W Y d}~n
d}~0 0 |  
||¡ dS )zöBind field to the schema, setting any necessary attributes on the
        field (e.g. parent and name).

        Also set field load_only and dump_only values if field_name was
        specified in `class Meta <marshmallow.Schema.Meta>`.
        TzField for "zJ" must be declared as a Field instance, not a class. Did you mean "fields.z()"?N)r   r€   Z_bind_to_schemaÚ	TypeErrorr‚   r=   Ú
issubclassr   r&   rl   r  )rˆ   r(   r¸   r¢   Úmsgr%   r%   r)   r   a  s    

þÿ
zSchema._bind_field)rº   )rj   r_   c                C  s(   | j |d|||d�}| j |d|||d�S )NF)rá   r£   r_   rº   T©Ú_invoke_processors)rˆ   rj   r£   r_   rº   r%   r%   r)   r»   |  s    
ÿ
ÿzSchema._invoke_dump_processors)rj   r_   r�   c                C  s,   | j |d||||d�}| j |d||||d�S )NT)rá   r£   r_   rº   r�   Fr  )rˆ   rj   r£   r_   rº   r�   r%   r%   r)   rã   ‰  s     úúzSchema._invoke_load_processors)r­   r_   c                C  sb  | j t D �]P\}}}t| |ƒ}|d }z| j| }	W nL ty‚ }
 z4|| jv r\W Y d }
~
q
td|› d�ƒ|
‚W Y d }
~
n
d }
~
0 0 |	jd ur”|	jn|}|�rt|ƒD ]b\}}z||	j	pº| }W n tyÒ   Y q¦0 | j
||||| jjrì|nd d�}|tu r¦| |d ¡ q¦q
z||	j	�p| }W n t�y4   Y q
0 | j
||||d�}|tu r
| |d ¡ q
d S )Nr(   ú"z" field does not exist.rÌ   )r¬   r£   r(   r­   )r\   r   r1   r   rd   r’   r„   r¶   rÏ   rÑ   r¯   r@   r~   r   Úpop)rˆ   r­   r£   r_   rb   rT   Úvalidator_kwargsÚ	validatorr(   r¸   r¢   r¶   rÃ   Úitemr®   Zvalidated_valuer%   r%   r)   rä   ¥  sL    

(ÿûüzSchema._invoke_field_validators)râ   )r­   rá   r_   r�   râ   c                C  s    | j t D ]�\}}	}
|	|krq
t| |ƒ}|r6|
d r6q
|
 dd¡}|r‚|s‚tt||ƒƒD ]&\}\}}| j||||||||d� qXq
| j|||||||d� q
d S )NZskip_on_field_errorsrÚ   F)rº   r­   r_   r�   r©   rÚ   )rº   r­   r_   rÚ   r�   )r\   r   r1   rJ   rÏ   ÚziprÝ   )rˆ   r­   rá   r£   rº   r_   r�   râ   rb   Ú	hook_manyr
  r  rÚ   rÃ   r  Úorigr%   r%   r)   ræ   Ó  s8    
ø
ùz Schema._invoke_schema_validators)rj   rá   r_   c                  s¬   | j | D ]œ\}}}	||krq
t| |ƒ‰|	 dd¡}
ˆrv|sv|
r^‡ ‡‡fdd„t||ƒD ƒ}q¦‡ ‡‡fdd„|D ƒ}q
|
r’ˆ||fdˆiˆ ¤Ž}q
ˆ|fdˆiˆ ¤Ž}q
|S )NrÚ   Fc                   s&   g | ]\}}ˆ||fd ˆiˆ ¤Ž‘qS r°   r%   )r'   r  Úoriginal©r`   r_   Ú	processorr%   r)   r*     s   ÿz-Schema._invoke_processors.<locals>.<listcomp>c                   s    g | ]}ˆ|fd ˆiˆ ¤Ž‘qS r°   r%   )r'   r  r  r%   r)   r*     r³   r_   )r\   r1   rJ   r   )rˆ   rj   rá   r£   r_   rº   r`   rb   r  Zprocessor_kwargsrÚ   r%   r  r)   r  ý  s    

þzSchema._invoke_processors)Hrl   rm   rn   ro   rC   rÿ   ÚStringÚbytesÚdtÚdatetimeÚDateTimeÚfloatZFloatrt   ÚBooleanrƒ   ZRawrN   r“   ÚintZIntegerÚuuidÚUUIDÚtimeZTimeÚdateÚDateÚ	timedeltaZ	TimeDeltaÚdecimalÚDecimalrŠ   rp   r‹   rŒ   rs   rA   r   rð   r0   r\   r>   rY   rž   ÚpropertyrŸ   rq   r¡   r¤   r§   Ústaticmethodr¯   r±   r½   r¾   r   rÀ   rÖ   rØ   rÝ   rà   rÕ   r”   rï   r—   r  r   r»   rã   rä   ræ   r  r%   r%   r%   r)   r‰     s¨   
5òþ^ö 6ü 
"õy÷'ú+ö.ø'ögKÿ7÷1ùr‰   )Ú	metaclass)Bro   Ú
__future__r   r�   r  r  r!  r7   r5   r‡   r9   rÁ   r  r…   Úabcr   Úcollectionsr   r   Úcollections.abcr   Ú	itertoolsr   Zmarshmallowr   r	   r
   r   rÿ   Zmarshmallow.decoratorsr   r   r   r   r   r   Zmarshmallow.error_storer   Zmarshmallow.exceptionsr   r   r   Zmarshmallow.orderedsetr   Zmarshmallow.utilsr   r   r   r   r   r   r   r   r   Zmarshmallow.warningsr    ÚTYPE_CHECKINGZmarshmallow.fieldsr!   r-   r<   r.   rs   Z	SchemaABCr‰   Z
BaseSchemar%   r%   r%   r)   Ú<module>   sN    ,}0        !