
    h                       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jp                  rddl9m:Z: ddZ;ddZ< G d de      Z= G d d      Z> G d dej~                  e=      Z@e@ZAy)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)Fieldc                    | j                         D cg c]#  \  }}t        |t        j                        r||f% c}}S c c}}w )zKGet fields from a class

    :param attrs: Mapping of class attributes
    )itemsr   r	   FieldABC)attrs
field_namefield_values      P/var/www/html/eduruby.in/venv/lib/python3.12/site-packages/marshmallow/schema.py_get_fieldsr*   2   sA     (-{{}#J";> 
[!  s   (A 
SchemaMetac                    t        j                  |       }t        j                  t        j
                  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              3  \   K   | ]$  }t        t        |d |j                               & yw)_declared_fieldsN)r*   getattr__dict__).0r	   s     r)   	<genexpr>z%_get_fields_by_mro.<locals>.<genexpr>M   s0      	
  0$--@	
s   *,Nr   )inspectgetmro	functoolsreduceoperatoriadd)klassmros     r)   _get_fields_by_mror<   @   sL     ..
C 	
 EQrE
		
 		 	    c                       e Zd ZU dZded<   ded<   ded<   ded<   	 	 	 	 	 	 	 	 d fd	Zeef	 	 	 	 	 	 	 	 	 dd
       Z fdZ	ddZ
 x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]r.   c                   |j                  d      }t        |dd      }|sD|D ]=  }t        |d      st        |j                  d      s'|j                  j                  } n d}t        |      }|D ]  \  }}	||= 
 t        |   | |||      }
t        |
      }|
j                  }|
j                  ||      |
_
        |t        |
j                  j                  j                               z  }| j                  |
||t              |
_        |
S )Nr@   orderedF)rF   )r:   
cls_fieldsinherited_fieldsdict_cls)getr/   hasattrr@   rF   r*   super__new__r<   rC   rB   listincluder$   get_declared_fieldsdictr.   )mcsnamebasesr&   metarF   base_rG   r'   _r:   rH   	__class__s               r)   rM   zSchemaMeta.__new__c   s    yy $	51
   5&)gejj).L#jj00G 
   '
 ( 	"MJj!	"T5%8-e4zz ((w(?
d5::--33566
 "%!8!8!-	 "9 "
 r=   c                     |||z         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``.
         )rR   r:   rG   rH   rI   s        r)   rP   zSchemaMeta.get_declared_fields   s    $ (:566r=   c                    t         |   |||       |r,| j                  j                  rt	        j                  ||        | j                         | _        y N)rL   __init__rB   registerr
   resolve_hooks_hooks)clsrS   rT   r&   rX   s       r)   r]   zSchemaMeta.__init__   sC    ue,CHH%%##D#.&&(
r=   c                b   t        j                  |       }t        t              }t	        |       D ]]  |D ]  }	 |j
                     } n 	 |j                  }|j                         D ]"  \  }}||   j                  fd|D               $ _ |S # t        $ r Y hw xY w# t        $ r Y |w xY w)zAdd in the decorated processors

        By doing this after constructing the class, we let standard inheritance
        do all the hard work.
        c              3  .   K   | ]  \  }}||f  y wr\   rZ   )r1   manykwargs	attr_names      r)   r2   z+SchemaMeta.resolve_hooks.<locals>.<genexpr>   s!      &6BdFD&1&s   )r4   r5   r   rN   dirr0   KeyError__marshmallow_hook__r$   extendAttributeError)	ra   r;   hooksparentattrhook_configtagconfigrf   s	           @r)   r_   zSchemaMeta.resolve_hooks   s     nnS!9DT9JS 	I  !??95D  --  $/#4#4#6 KC #J%% &FL& 1	> 1    " s#   BB"	BB"	B.-B.)rS   strrT   ztuple[type, ...]r&   zdict[str, typing.Any]returnr+   )
r:   r+   rG   list[tuple[str, Field]]rH   rt   rI   
type[dict]rs   rD   )rs   'dict[str, list[tuple[str, bool, dict]]])__name__
__module____qualname____doc____annotations__rM   classmethodrQ   rP   r]   r_   __classcell__)rX   s   @r)   r+   r+   W   s     J
&&))  ) %	)
 
)V   $77 ,7 2	7
 7 
7 7&))r=   c                      e Zd ZdZdddZy)
SchemaOptsz/Defines defaults for `marshmallow.Schema.Meta`.c                R   t        |dd      | _        t        | j                  t        t        f      st        d      t        |dd      | _        t        | j                  t        t        f      st        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       t        |dt              }nt        }t        |d|      | _        t        |d      rt        j                  dt        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      | _        y )Nr   rZ   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
timeformatjson_modulezKThe json_module class Meta option is deprecated. Use render_module instead.   
stacklevelrender_modulerF   zThe `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unknownr^   rd   F)r/   r   
isinstancerN   tuple
ValueErrorr   r   r   r   r   rK   warningswarnr!   jsonr   rF   r   rO   r   r   r    r   r   r^   rd   )selfrU   rF   r   s       r)   r]   zSchemaOpts.__init__   s   dHb1$++e}5GHH!$b9$//D%=9KLL;;4??X  tY3$,,u6ABB!$d;%d,<dC!$d;4'MM],
 $D->M M$T?MJ4#MM\ - tY8#D.$?tY3 {B7 {B77iQV8WXj$7D&%0	r=   N)F)rU   r?   rF   bool)rw   rx   ry   rz   r]   rZ   r=   r)   r   r      s
    9*1r=   r   c                     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j0                  ej2                  ej4                  ej6                  ej8                  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      Z)ddddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d=dZ*d>dZ+e,d?d       Z-e.dd	 	 	 	 	 d@d       Z/	 	 	 	 	 	 dAdZ0dBdZ1e2ddd        Z3d!d"dCd#Z4dd"dDd$Z5dd"dDd%Z6d!de7dd&	 	 	 	 	 	 	 dEd'Z8dddd(	 	 	 	 	 	 	 dFd)Z9dddd(	 	 	 	 	 	 	 dGd*Z:dd	 	 	 	 	 	 	 	 	 	 	 dHd+Z;ddd,	 	 	 	 	 	 	 dId-Z<dddd.d/	 	 	 	 	 	 	 	 	 dJd0Z=dKd1Z>dKd2Z?dKd3Z@dLd4ZAdLd5ZBdd6	 	 	 dMd7ZC	 	 	 	 	 	 dNd8ZDdOd9ZEd!d:	 	 	 	 	 	 	 	 	 dPd;ZFdd6	 	 	 	 	 dQd<ZGy)R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?   rC   rA   rB   rD   r.   rv   r`   c                      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<   y)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.Opts):
                        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   r   z!typing.ClassVar[dict[str, Field]]rO   r   ztyping.ClassVar[bool]rd   ztyping.ClassVar[str]r   r   r   rA   r   rF   r   r   r   r   r^   N)rw   rx   ry   rz   r{   rZ   r=   r)   r@   r   Z  s    &	P =<<@@	 32	 >=	 $#O((I,,Q((I "!	 '&`++e??7??7%%	 ('	r=   r@   NrZ   )onlyr   rd   contextr   r   partialr   c               n   |t        |      st        d      t        |      st        d      t        j                  | j                        | _        || j                  j                  n|| _        || _        t        | j                  j                        t        |      z  | _
        | j                  j                  | _        t        |      xs t        | j                  j                        | _        t        |      xs t        | j                  j                        | _        || _        || j                  j                  n
t!        |      | _        |rt#        j$                  dt&        d       |xs i | _        | j+                          i | _        i | _        i | _        | j3                          i }	|	j5                  | j6                         t9        | j:                  j<                        D ]  }
|	j5                  t?        |
di                |	j5                  | j@                  xs i        |	| _         y )Nz""only" should be a list of stringsz%"exclude" should be a list of stringszThe `context` parameter is deprecated and will be removed in marshmallow 4.0. Use `contextvars.ContextVar` to pass context instead.r   r   r   )!r   r   copydeepcopyr.   declared_fieldsrB   rd   r   setr   rF   r   r   r   r   r    r   r   r!   r   _normalize_nested_optionsr   load_fieldsdump_fields_init_fieldsupdater   reversedrX   __mro__r/   r   )r   r   r   rd   r   r   r   r   r   messagesra   s              r)   r]   zSchema.__init__  s    M$$7*+OPPW%*+RSS#}}T-B-BC&*lDIINN		HKIII
LI yy((YC3tyy/B/B+CYC3tyy/B/B+C  II1': 	
 MMH,	 }"&&((*-/-/445DNN223 	@COOGC)92>?	@++1r2&r=   c                P    d| j                   j                   d| j                   dS )N<z(many=z)>)rX   rw   rd   r   s    r)   __repr__zSchema.__repr__  s&    4>>**+6$))B??r=   c                2    | j                   rt        S t        S )z'`dict` type to return when serializing.)rF   r   rQ   r   s    r)   
dict_classzSchema.dict_class  s     <<r=   GeneratedSchema)rS   c                   t        dt        | dt              fddi      }t        || fi |j                         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
        GeneratedMetar@   r^   F)r?   r/   objectr   )ra   r   rS   r@   s       r)   	from_dictzSchema.from_dict  sL    4 gc66:<z5>Q
 D3&"AV[[]"AFD"ABBr=   c                    y)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.
        NrZ   )r   errordatard   re   s        r)   handle_errorzSchema.handle_error  s    r=   c                    t        |||      S )zDefines how to pull values from an object to serialize.

        .. versionchanged:: 3.0.0a1
            Changed position of ``obj`` and ``attr``.
        )r   )r   objrn   defaults       r)   get_attributezSchema.get_attribute$  s     dG,,r=   indexc                   	  | |      }|S # t         $ r<}|j                  |j                  ||       |j                  xs t        cY d}~S d}~ww xY w)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   s          r)   _call_and_storezSchema._call_and_store.  sV    	/%E   	/##ENNJe#L ##.w.		/s    	A1AAAFrd   c               J   |r#|!|D cg c]  }| j                  |d       c}S | j                         }| j                  j                         D ]K  \  }}|j	                  ||| j
                        }|t        u r-|j                  |j                  n|}|||<   M |S c c}w )zSerialize ``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
        Fr   )accessor)
_serializer   r   r$   	serializer   r   data_key)	r   r   rd   dretrf   	field_objr   keys	            r)   r   zSchema._serializeB  s     CO<?@qDOOAEO2@@oo$($4$4$:$:$< 	 Iy''	3ASAS'TE(1(:(:(F)$$ICCH	 
 As   B c                  || j                   n
t        |      }| j                  t           r| j	                  t        |||      }n|}| j                  ||      }| j                  t           r| j	                  t        |||      }|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.
        )rd   original_datar   )rd   r   r`   r   _invoke_dump_processorsr   r   )r   r   rd   processed_objresults        r)   dumpzSchema.dumpT  s    " !Ltyyd4j;;x  88#D 9 M  MT:;;y!116C 2 F r=   c               |    | j                  ||      } | j                  j                  j                  |g|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   rB   r   dumps)r   r   rd   argsre   
serializeds         r)   r   zSchema.dumpsv  s=     YYsY.
,tyy&&,,ZI$I&IIr=   )rd   r   r   r   c                  | j                   j                  }|r|nd}|r|t              s%|j                  | j                  d   g|       g }|S t              D 	
cg c]4  \  }	}
| j                  t        j                  t        |
      |d|||	      6 }}	}
|S | j                         }t        t              s#|j                  | j                  d   g|       |S t        |      }| j                  j                         D ]  \  }}|j                  |j                  n|}j!                  |t"              }|t"        u r|du s|r||v rIi }|r:|dz   }t%        |      }|D cg c]  }|j'                  |      s||d  }}||d<   n|||d<   |||ffd		}| j)                  |||||
      }|t"        us|j*                  xs |}t-        |||        |t.        k7  r| j                  j                         D ch c]  \  }}|j                  |j                  n|! }}}t1              |z
  D ]E  }|   }|t2        k(  r|||<   |t4        k(  s!|j                  | j                  d   g||r|nd       G |S c c}
}	w c c}w c c}}w )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   F)r   rd   r   r   r   T.r   c                .     |j                   | |fi |S r\   )deserialize)valr   r'   d_kwargsr   s       r)   getterz#Schema._deserialize.<locals>.getter  s-     1900" #	 r=   r   r   r'   r   r   r   )rB   r   r   r   r   	enumerate_deserializetypingcastrQ   r   r   r   r   r$   r   rJ   r   len
startswithr   	attributer   r   r   r   r   )r   r   r   rd   r   r   r   r   ret_lidxr   ret_dpartial_is_collectionrf   r   r'   	raw_valuer   prefix
len_prefixfsub_partialr   r   r   r   s    `                        r)   r   zSchema._deserialize  s   : yy--%4 &'')<)<V)D(EU'S L #,D/
 Q %%D!,$/" ' '! & 
 
 L!$(##T%8%8%@$A#Oz w %2'$:!(,(8(8(>(>(@ *1$	9*3*<*<*HI&&i  !HHZ9	'$-)w2F ('#-F!$VJ07#+,1<<;O*+#K # +6HY'(*1HY' $-h ,, &") + -  '#--:CeS%0U*1V '! 261A1A1G1G1I-
I +4*<*<*HI&&jX  t9v- 	C IE')%*c
 E)#//!00;<&2U	 Y
D#8s   9I>%J<J?$J	rd   r   r   c               .    | j                  ||||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rd   r   r   postprocess)_do_load)r   r   rd   r   r   s        r)   loadzSchema.load  s%    > }}tWg4  
 	
r=   c               z     | j                   j                  j                  |fi |}| j                  ||||      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   )rB   r   loadsr   )r   	json_datard   r   r   re   r   s          r)   r   zSchema.loads  s<    < -tyy&&,,YA&AyyD'7yKKr=   c                  	 |r |||||       y  ||||       y # t         $ r}	|	j                  }
|
t        k(  rt        }n^d }	 | j                  |
   }n,# t        $ r  |
| j
                  v r| j
                  |
   }Y nw xY w|r|j                  |j                  n|
}n|
}|j                  |	j                  ||       Y d }	~	y d }	~	ww xY w)N)r   rd   r   )	r   r'   r   r   rh   r   r   r   r   )r   validator_funcoutputr   r   rd   r   pass_originalr   errr'   r   r   s                r)   _run_validatorzSchema._run_validator=  s    	Iv}gDQvwTB 	IJV#!*.	E $J 7I E!T%9%99$($8$8$D	E  %--9 "**'   *H##CLL(%#HH)	Is=     	CCAC&A>;C=A>>A CCrd   r   c                   	 | j                  |||d       i S # t        $ rB}t        j                  t        t
        t        t
           f   |j                        cY d}~S d}~ww xY w)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)rd   r   r   N)r   r   r   r   rQ   rr   rN   r   )r   r   rd   r   excs        r)   validatezSchema.validated  sY    0	CMM$T7MN 	  	C;;tCcN3S\\BB	Cs    	A$7AA$A$Tr   c          	     p   t               }i }|| j                  n
t        |      }|| j                  n
t	        |      }|| j
                  }| j                  t           r	 | j                  t        ||||      }n|}|s| j                  ||||      }
| j                  ||
|       | j                  t           rEt        |j                        }| j                  |d|
||||       | j                  |d|
||||       |j                  }|s0|r.| j                  t            r	 | j                  t         |
|||      }
|r%t        ||
      }| j#                  ||||	       |
S # t        $ r}	|	j                         }d}
Y d}	~	d}	~	ww xY w# t        $ r}	|	j                         }Y d}	~	pd}	~	ww xY w)
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)rd   r   r   )r   rd   r   r   )r   r   rd   T)r   	pass_manyr   r   rd   r   field_errorsF)r   r   r  )r   rd   r   r   r    r   r`   r   _invoke_load_processorsr   normalized_messagesr   _invoke_field_validatorsr   errors_invoke_schema_validatorsr   r   )r   r   rd   r   r   r   r   r  processed_datar  r   r  r  s                r)   r   zSchema._do_load  s   8 !l') Ltyyd4j  LL1': 	
 ?llG;;x 2!%!=!=dT7 "> " "N&&' ' F ))'f4 *  {{+,#K$6$67.. +""&#!- /  .. +#"&#!- /  !''Fkdkk).D	7!99!!&* ' : F !&tGCc4dGDIs # 2002-12d ' 7 446F7s0   !E) &F )	F2F

F	F5F00F5c           	        | j                   ^| j                  d| j                   d       | j                  | j                   D cg c]  }|j                  dd      d    c}      | _         | j                  rQ| j                  d| j                  d       | j                  | j                  D cg c]	  }d|vs| c}      | _        yyc c}w c c}w )	zVApply then flatten nested schema options.
        This method is private API.
        Nr   intersectionr      r   r   union)r   _Schema__apply_nested_option	set_classsplitr   )r   fields     r)   r   z Schema._normalize_nested_options  s     99 &&vtyy.IDII'V5C(;A(>'VWDI<<&&y$,,H>>$(LLE5Cu4DEDL	  (W Fs   C	-	C7Cc                   |D cg c]  }d|v s|j                  dd       }}t        t              }|D ]  \  }}||   j                  |        t	        |j                               D ]~  \  }	}
| j                  |
      }t        | j                  |	   |d      }|r2|dk(  r|| j                  |      z  }|dk(  r|| j                  |      z  }t        | j                  |	   ||        yc c}w )z%Apply nested options to nested fieldsr   r  rZ   r  r  N)
r  r   rN   appenditerr$   r  r/   r   setattr)r   option_namefield_namesset_operationrS   nested_fieldsnested_optionsrm   nested_namesr   optionsnew_optionsoriginal_optionss                r)   __apply_nested_optionzSchema.__apply_nested_option  s     9DSsd{C+SS$T*$1 	8 FL6")),7	8 !!5!5!78 	ILC..1K&t';';C'@+rR G+4>>2B#CCK N24>>2B#CCKD((-{KH	I Ts
   	C-C-c                X   | j                   j                  r&| j                  | j                   j                        }ng| j                  | j                  j	                               }| j                   j
                  r(|| j                  | j                   j
                        z  }| j                         }| j                  $| j                  | j                        }|||z
  z  }n|}| j                  r!|| j                  z
  }|| j                  |z
  z  }|rd|  d| d}t        |      | j                         }|D ]G  }| j                  j                  |t        j                               }| j                  ||       |||<   I | j                         | j                         }	}|j                         D ](  \  }}|j                  s|||<   |j                   r$||	|<   * |	j                         D 
cg c]  \  }
}|j"                  |j"                  n|
! }}
}t%        |      t%        t'        |            k7  r;|D ch c]  }|j)                  |      dkD  s| }}t        dt+        |             |j                         D 
cg c]  \  }
}|j,                  xs |
 }}
}t%        |      t%        t'        |            k7  r;|D ch c]  }|j)                  |      dkD  s| }}t        dt+        |             || _        |	| _        || _        yc c}}
w c c}w c c}}
w c c}w )zUpdate self.fields, self.load_fields, and self.dump_fields based on schema options.
        This method is private API.
        NzInvalid fields for z: r   r  zThe 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: zThe attribute argument for one or more fields collides with another field's name or attribute argument. Check the following field names and attribute arguments: )rB   r   r  r   keysr   r   r   r   r   rJ   	ma_fieldsInferred_bind_fieldr$   r   r   r   r   r   countrN   r   r   r   )r   available_field_namesinvalid_fieldsr  messagefields_dictr'   r   r   r   rS   dump_data_keysxdata_keys_duplicatesr   load_attributesattributes_duplicatess                    r)   r   zSchema._init_fields  s,    99$(NN4993C3C$D!$(NN43G3G3L3L3N$O!yy##%		8L8L)MM%)99 :>..:SKk,AAAN/K << &4Kdll-BBBN+D6N3C1EGW%%oo'% 	0J,,00Y=O=O=QRIZ3&/K
#	0
 $(??#4doo6G[%0%6%6%8 	4!J	&&*3J'&&*3J'		4 $/#4#4#6
i #,"4"4"@IdJ
 
 ~#c.&9"::)$^-A-A!-Dq-H$  $ ' (,,@'A&BD  CNBSBSBUVYT33==0D0VV3s?';#<<*%o.C.CA.F.J%! % ( )--B(C'DF  "&&9

$ W%s$   3$L>LLL!	L'#L'c                     y)zqHook to modify a field when it is bound to the `Schema <marshmallow.Schema>`.

        No-op by default.
        NrZ   )r   r'   r   s      r)   on_bind_fieldzSchema.on_bind_fieldZ  s    
 	r=   c                X   || j                   v rd|_         || j                  v rd|_        	 |j                  ||        | j                  ||       y# t        $ rO}t	        |t
              r9t        |t        j                        rd| d|j                   d}t        |      | d}~ww xY w)zBind 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   _bind_to_schema	TypeErrorr   r?   
issubclassr	   r%   rw   r8  )r   r'   r   r   msgs        r)   r,  zSchema._bind_fielda  s     '"&I'"&I	%%j$7 	:y1  	 )T*z)T]]/S!* .,,5,>,>+?tE 
  n%/	s   A 	B)A
B$$B))r   c               Z    | j                  |d|||      }| j                  |d|||      S )NF)r
  r   rd   r   T_invoke_processors)r   rp   r   rd   r   s        r)   r   zSchema._invoke_dump_processors|  sI     &&5t$m ' 
 &&4d] ' 
 	
r=   c               ^    | j                  |d||||      }| j                  |d||||      S )NT)r
  r   rd   r   r   Fr?  )r   rp   r   rd   r   r   s         r)   r  zSchema._invoke_load_processors  sW     &&' ' 
 &&' ' 
 	
r=   c          	        | j                   t           D ]  \  }}}t        | |      }|d   }	 | j                  |   }	|	j                  |	j                  n|}|rqt        |      D ]b  \  }}	 ||	j                  xs |   }| j                  ||||| j                  j                  r|nd       }|t        u sQ|j                  |d        d 	 ||	j                  xs |   }| j                  ||||      }|t        u s|j                  |d         y # t        $ r)}
|| j
                  v rY d }
~
t        d| d      |
d }
~
ww xY w# t        $ r Y w xY w# t        $ r Y Lw xY w)Nr'   "z" field does not exist.r   )r   r   r'   r   )r`   r   r/   r   rh   r   r   r   r   r   r   rB   r   r   pop)r   r   r   rd   rf   rW   validator_kwargs	validatorr'   r   r   r   r   itemr   validated_values                   r)   r  zSchema._invoke_field_validators  s   .2kk).D +	3*Iq*i0I),7JU KK
3	 '0&8&8&D	""*  !*4 7IC7 $Y%8%8%FJ G +/*>*>(1!&'/(3*.))*@*@3d +? + +g5 HHZ67 3 !4!4!B
CE '+&:&:$-"#+$/	 '; 'O ''1T2W+	3  U!5!55 1ZL0G!HIuTU $    sA   D*E
E	ED=-D==E	EE	E! E!)r  c               @   | j                   t           D ]  \  }}	}
|	|k7  rt        | |      }|r|
d   r!|
j                  dd      }|r<|s:t	        t        ||            D ]!  \  }\  }}| j                  ||||||||       # q| j                  |||||||        y )Nskip_on_field_errorsr  F)r   r   rd   r   r   r  )r   r   rd   r  r   )r`   r   r/   rJ   r   zipr  )r   r   r
  r   r   rd   r   r  rf   	hook_manyrE  rF  r  r   rG  origs                   r)   r  z Schema._invoke_schema_validators  s     7;kkBR6S 	2Iy"2I%i0I 01G H,00%HMI)23t]3K)L 
%C$''!&*$/! '!&3 ( 	
 ##"/ +"/# $ +	r=   c          
     X   | j                   |   D ]  \  }}}	||k7  rt        | |      }
|	j                  dd      }|rF|sD|r)t        ||      D cg c]  \  }} |
||fd|i| }}}Z|D cg c]  } |
|fd|i| }}s|r |
||fd|i|} |
|fd|i|} |S c c}}w c c}w )Nr  Frd   )r`   r/   rJ   r   )r   rp   r
  r   rd   r   re   rf   rL  processor_kwargs	processorr  rG  originals                 r)   r@  zSchema._invoke_processors  s     7;kk#6F 	<2Iy"2I%i0I,00%HMI  /:$.N*D( "$FtFvFD 
 NRRTId@@@RDR }J4J6J ;D;F;%	<& 
 Ss   B!.B')r   ztypes.StrSequenceOrSet | Noner   types.StrSequenceOrSetrd   bool | Noner   zdict | Noner   rR  r   rR  r   $bool | types.StrSequenceOrSet | Noner   
str | None)rs   rr   )rs   ru   )r   rD   rS   rr   rs   ztype[Schema])r   r   r   rA   rd   r   )r   rA   rn   rr   r   rA   )r   rA   rd   r   )r   rA   rd   rS  )r   Rtyping.Mapping[str, typing.Any] | typing.Iterable[typing.Mapping[str, typing.Any]]r   r   rd   r   rs   ztyping.Any | list[typing.Any])r   rV  rd   rS  r   rT  r   rU  )r   zstr | bytes | bytearrayrd   rS  r   rT  r   rU  )r   ztypes.SchemaValidatorr   r   rd   r   r   rT  r  r   r   z
int | None)r   rV  rd   rS  r   rT  rs   zdict[str, list[str]])
r   rV  rd   rS  r   rT  r   rU  r   r   )rs   None)r'   rr   r   r"   rs   rW  )rp   rr   rd   r   )rp   rr   rd   r   r   rT  )r   r   rd   r   )
r   r   r
  r   rd   r   r   rT  r  r   )rp   rr   r
  r   rd   r   )Hrw   rx   ry   rz   rr   r*  StringbytesdtdatetimeDateTimefloatFloatr   Booleanr   RawrN   r   intIntegeruuidUUIDtimeTimedateDate	timedelta	TimeDeltadecimalDecimalr   r{   r   r   r   rC   r   r  r.   r`   r@   r]   r   propertyr   r|   r   r   r   staticmethodr   r   r   r   r   r   r   r   r  r  r   r   r  r   r8  r,  r   r  r  r  r@  rZ   r=   r)   r   r     s   2j 	Yy
Y''yiy}}immY]]Y		9>>


i))**-L) " &(NN' &#/^ 
 %M4$I )+&+68F38Y Y| /3*, #,.,.8<"4' ,4' (	4'
 4' 4' *4' *4' 64' 4'l@   
 &	C C 	C
 
C C@$,6AE- MQ  & ;@ $ <@  D AE J2 p?p  p p 
'pr !8<"!
?!
 !
 6!
 !
N !8<"L*L 	L
 6L LV !%I-%I  %I %I 6%I %I %I\ !8<?  6 
N !8<" e?e e 6e e eN"I&I'V28 <@

'+



 
 6
8,3n #(  ( 	( ( 6( (b  	 r=   r   )	metaclass)rs   rt   )r:   r+   )Brz   
__future__r   r   r[  rZ  rk  r6   r4   r   r8   r   rc  r   abcr   collectionsr   r   collections.abcr   	itertoolsr   marshmallowr	   r
   r   r   r*  marshmallow.decoratorsr   r   r   r   r   r   marshmallow.error_storer   marshmallow.exceptionsr   r   r   marshmallow.orderedsetr   marshmallow.utilsr   r   r   r   r   r   r   r   r    marshmallow.warningsr!   TYPE_CHECKINGmarshmallow.fieldsr"   r*   r<   r+   r   	SchemaABCr   
BaseSchemarZ   r=   r)   <module>r     s    | "            0 # ! 3 3 +  / T T -
 
 
 >	(	.z zz-1 -1`VT^^z Vr  
r=   