o
    DDi                     @  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mZ ddlmZ ddlmZmZ ddlmZ ddlmZm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#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/m0Z0m1Z1m2Z2m3Z3 ej4rddl5m6Z6 dddZ7d ddZ8G dd deZ9G dd dZ:G dd de9dZ;e;Z<dS )!zvThe `Schema <marshmallow.Schema>` class, including its metaclass and options (`class Meta <marshmallow.Schema.Meta>`).    )annotationsN)ABCMeta)defaultdict)MappingSequence)zip_longest)class_registrytypes)fields)EXCLUDEINCLUDERAISEmissing)	POST_DUMP	POST_LOADPRE_DUMPPRE_LOAD	VALIDATESVALIDATES_SCHEMA)
ErrorStore)SCHEMAStringNotCollectionErrorValidationError)
OrderedSet)	get_valueis_collectionis_sequence_but_not_string	set_value)Fieldreturnlist[tuple[str, Field]]c                 C  sb   g }|   D ](\}}t|tr!t|tjr!td| d|j dt|tjr.|||f q|S )zKGet fields from a class

    :param attrs: Mapping of class attributes
    zField for "zJ" must be declared as a Field instance, not a class. Did you mean "fields.z()"?)	items
isinstancetype
issubclass	ma_fieldsr   	TypeError__name__append)attrsret
field_namefield_value r-   K/var/www/Datamplify/venv/lib/python3.10/site-packages/marshmallow/schema.py_get_fields-   s   r/   klass
SchemaMetac                 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__).0baser-   r-   r.   	<genexpr>N   s    
z%_get_fields_by_mro.<locals>.<genexpr>Nr   )inspectgetmro	functoolsreduceoperatoriadd)r0   mror-   r-   r.   _get_fields_by_mroA   s   
r@   c                      sl   e Zd ZU dZded< ded< ded< ded< d fddZeefd ddZ fddZ	d!ddZ
  ZS )"r1   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.
    r#   Meta
typing.AnyoptsOPTIONS_CLASSdict[str, Field]r2   namestrbasestuple[type, ...]r)   dict[str, typing.Any]r   c           
        s~   | d}t|}|D ]\}}||= qt | |||}t|}	|j}|||_|t|jj	
 7 }| j|||	td|_|S )NrA   )r0   
cls_fieldsinherited_fieldsdict_cls)getr/   super__new__r@   rA   rD   rC   listincluder!   get_declared_fieldsdictr2   )
mcsrF   rH   r)   metarK   r+   _r0   rL   	__class__r-   r.   rP   d   s    
zSchemaMeta.__new__r0   rK   r    rL   rM   
type[dict]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-   )rU   r0   rK   rL   rM   r-   r-   r.   rS      s   zSchemaMeta.get_declared_fieldsc                   s6   t  ||| |r| jjrt||  |  | _d S N)rO   __init__rC   registerr   resolve_hooks_hooks)clsrF   rH   r)   rX   r-   r.   r\      s   zSchemaMeta.__init__'dict[str, list[tuple[str, bool, dict]]]c              
     s   t | }tt}t| D ]@ |D ]}z|j  }W n	 ty#   Y qw  nqz|j}W n	 ty5   Y qw |	 D ]\}}|| 
 fdd|D  q:q|S )zAdd 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 r[   r-   )r5   manykwargs	attr_namer-   r.   r7      s    
z+SchemaMeta.resolve_hooks.<locals>.<genexpr>)r9   r:   r   rQ   dirr4   KeyError__marshmallow_hook__AttributeErrorr!   extend)r`   r?   hooksparentattrhook_configtagconfigr-   rd   r.   r^      s.   

zSchemaMeta.resolve_hooks)rF   rG   rH   rI   r)   rJ   r   r1   )
r0   r1   rK   r    rL   r    rM   rZ   r   rE   )r   ra   )r'   
__module____qualname____doc____annotations__rP   classmethodrT   rS   r\   r^   __classcell__r-   r-   rX   r.   r1   X   s   
 c                   @  s   e Zd ZdZdddZdS )
SchemaOptsz/Defines defaults for `marshmallow.Schema.Meta`.rV   r#   c                 C  s   t |dd| _t| jttfstdt |dd| _t| jttfs&tdt |dd | _t |dd | _t |dd | _	t |d	t
| _t |d
d| _t |di | _t |dd| _t |dd| _t |dt| _t |dd| _t |dd| _d S )Nr
   r-   z(`fields` option must be a list or tuple.excludez"`exclude` must be a list or tuple.
dateformatdatetimeformat
timeformatrender_moduleindex_errorsTrR   	load_only	dump_onlyunknownr]   rb   F)r3   r
   r"   rQ   tuple
ValueErrorrx   ry   rz   r{   jsonr|   r}   rR   r~   r   r   r   r]   rb   )selfrV   r-   r-   r.   r\      s"   zSchemaOpts.__init__N)rV   r#   )r'   rq   rr   rs   r\   r-   r-   r-   r.   rw      s    rw   c                   @  sd  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&e'Z(de d< 	 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dd%d&Z,dd)d*Z-e.d+d,dd0d1Z/dd6d7Z0dd;d<Z1e2dd=d>d?Z3d@dAddBdCZ4ddAddDdEZ5ddAddFdGZ6d@de7ddHddNdOZ8ddddPddQdRZ9ddddPddUdVZ:dd=dd\d]Z;ddd^dd`daZ<ddddbdcddedfZ=ddhdiZ>ddjdkZ?ddldmZ@ddqdrZAddsdtZBdduddwdxZCddydzZDdd{d|ZEd@d}dddZFdduddd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 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
        Remove ``prefix`` parameter.

    .. versionchanged:: 4.0.0
        Remove ``context`` parameter.
    zdict[type, type[Field]]TYPE_MAPPINGzdict[str, str]error_messageszInvalid input type.zUnknown field.)r#   r   _default_error_messagesr#   rD   rZ   
dict_classrB   rC   rE   r2   ra   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S )zSchema.Metaaa  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.
        .. versionremoved:: 4.0.0 Remove ``ordered``.
        z,typing.ClassVar[tuple[str, ...] | list[str]]r
   
additionalz!typing.ClassVar[dict[str, Field]]rR   rx   ztyping.ClassVar[bool]rb   ztyping.ClassVar[str]ry   rz   r{   rB   r|   r}   r~   r   z$typing.ClassVar[types.UnknownOption]r   r]   N)r'   rq   rr   rs   rt   r-   r-   r-   r.   rA   9  s<   
 )rA   Nr-   )onlyrx   rb   r~   r   partialr   r   types.StrSequenceOrSet | Nonerx   types.StrSequenceOrSetrb   bool | Noner~   r   r   $bool | types.StrSequenceOrSet | Noner   types.UnknownOption | Nonec          
      C  s   |d urt |stdt |stdt| j| _|d u r#| jjn|| _|| _t	| jj
t	|B | _
t	|p=t	| jj| _t	|pHt	| jj| _|| _|d u rU| jjn|| _|   i | _i | _i | _|   i }|| j t| jjD ]}	|t|	di  qw|| jpi  || _d S )Nz""only" should be a list of stringsz%"exclude" should be a list of stringsr   )r   r   copydeepcopyr2   declared_fieldsrC   rb   r   setrx   r~   r   r   r   _normalize_nested_optionsr
   load_fieldsdump_fields_init_fieldsupdater   reversedrY   __mro__r3   r   )
r   r   rx   rb   r~   r   r   r   messagesr`   r-   r-   r.   r\     s8   
zSchema.__init__r   rG   c                 C  s   d| j j d| j dS )N<z(many=z)>)rY   r'   rb   r   r-   r-   r.   __repr__  s   zSchema.__repr__GeneratedSchema)rF   r
   rF   type[Schema]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
        GeneratedMetarA   r]   F)r#   r3   objectr   )r`   r
   rF   rA   r-   r-   r.   	from_dict  s   zSchema.from_dicterrorr   databoolc                K     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   rb   rc   r-   r-   r.   handle_error  s    zSchema.handle_errorobjrm   defaultc                 C  s   t |||S )zDefines how to pull values from an object to serialize.

        .. versionchanged:: 3.0.0a1
            Changed position of ``obj`` and ``attr``.
        )r   )r   r   rm   r   r-   r-   r.   get_attribute  s   zSchema.get_attributeindexc             
   C  sP   z| |}W |S  t y' } z|j|j||d |jptW  Y d}~S d}~w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   r-   r-   r.   _call_and_store  s   
zSchema._call_and_storeFrb   c                  sv   |r|dur fdd|D S    } j D ] \}}|j|| jd}|tu r*q|jdur2|jn|}|||< q|S )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
        Nc                   s   g | ]	} j |d dqS )Fr   )
_serialize)r5   dr   r-   r.   
<listcomp>      z%Schema._serialize.<locals>.<listcomp>)accessor)r   r   r!   	serializer   r   data_key)r   r   rb   r*   re   	field_objr   keyr-   r   r.   r     s   
zSchema._serializec                C  sf   |du r| j nt|}| jt r| jt|||d}n|}| j||d}| jt r1| 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

        .. 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)rb   original_datar   )rb   r   r_   r   _invoke_dump_processorsr   r   )r   r   rb   processed_objresultr-   r-   r.   dump  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

        .. 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   rC   r|   dumps)r   r   rb   argsrc   
serializedr-   r-   r.   r   @  s   zSchema.dumps)rb   r   r   r   =Mapping[str, typing.Any] | Sequence[Mapping[str, typing.Any]]r   r   types.UnknownOptiontyping.Any | list[typing.Any]c                  s  j j}|r|nd}|r/t sjjd g|d g }|S fddt D }|S  }	t tsEjjd g|d |	S t	}
j
 D ]i\}}|jdurZ|jn|} |t}|tu rqdu sp|
rq|v rqqNi }|
r|d tfddD }||d	< ndur|d	< |||f fd
d	}j||||d}|tur|jp|}t|	|| qNtkrdd j
 D }t | D ]"} | }tkr||	|< q̈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 | d |dqS )F)r   rb   r   r   r   )_deserialize)r5   idxr   )r   r   r   r   r-   r.   r   q  s    	z'Schema._deserialize.<locals>.<listcomp>T.c                   s"   g | ]}| r| d  qS r[   )
startswith)r5   f)
len_prefixprefixr-   r.   r     s
    

r   c                   s   |j | | fi |S r[   )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 r[   r   )r5   r+   r   r-   r-   r.   	<setcomp>      z&Schema._deserialize.<locals>.<setcomp>r   )rC   r}   r   r   r   	enumerater   r"   r   r   r   r!   r   rN   r   lenr   	attributer   r   r   r   r   )r   r   r   rb   r   r   r   r}   ret_lret_dpartial_is_collectionre   r   r+   	raw_valuer   sub_partialr   r   r   r
   r-   )r   r   r   r   r   r   r   r.   r   P  s   	
=





zSchema._deserializerb   r   r   c                C  s   | j ||||ddS )a2  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

        .. 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rb   r   r   postprocess)_do_load)r   r   rb   r   r   r-   r-   r.   load  s   
zSchema.loadsstr | bytes | bytearrayc               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 s: 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

        .. 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.
        .. versionchanged:: 4.0.0
            Rename ``json_module`` parameter to ``s``.
        r   )rC   r|   loadsr   )r   r   rb   r   r   rc   r   r-   r-   r.   r     s    zSchema.loadsvalidator_functypes.SchemaValidatorpass_originalr   
int | Nonec                C  s   z|r||||||d W d S |||||d W d S  t yk }
 zF|
j}|tkr+t}n,d }z| j| }W n tyG   || jv rE| j| }Y nw |rU|jd urR|jn|}n|}|j|
j||	d W Y d }
~
d S d }
~
ww )N)r   rb   r   r   )	r   r+   r   r
   rg   r   r   r   r   )r   r   outputr   r   rb   r   r   r   r   errr+   r   r   r-   r-   r.   _run_validator  s6   



 zSchema._run_validatorrb   r   dict[str, list[str]]c             
   C  sL   z| j |||dd W i S  ty% } ztd|jW  Y d}~S d}~ww )as  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.
        F)rb   r   r   r   N)r   r   typingcastr   )r   r   rb   r   excr-   r-   r.   validate+  s   zSchema.validateTr   r   c             
   C  s  t  }i }|du r| jnt|}|du r| jn|}|du r | j}| jt rKz| jt|||||d}W n tyJ }	 z|		 }d}
W Y d}	~	nd}	~	ww |}|s| j
|||||d}
| j||
|d | jt rt|j}| j|d|
|||||d | j|d|
|||||d |j}|s|r| jt rz| jt|
||||d}
W n ty }	 z
|		 }W Y d}	~	nd}	~	ww |rt|||
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)rb   r   r   r   )r   rb   r   r   )r   r   rb   T)r   pass_collectionr   r   rb   r   r   field_errorsF)r   r   r   )r   rb   r   r   r   r_   r   _invoke_load_processorsr   normalized_messagesr   _invoke_field_validatorsr   errors_invoke_schema_validatorsr   r   )r   r   rb   r   r   r   r   r   processed_datar   r   r   r   r-   r-   r.   r   F  s   






zSchema._do_loadNonec                 C  sh   | j dur| d| j d | dd | j D | _ | jr2| d| jd | dd | jD | _dS 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r5   fieldr-   r-   r.   r     s    z4Schema._normalize_nested_options.<locals>.<listcomp>rx   unionc                 S  s   g | ]}d |vr|qS )r   r-   r  r-   r-   r.   r     s    )r   _Schema__apply_nested_option	set_classrx   r   r-   r-   r.   r     s   

z Schema._normalize_nested_optionsc                 C  s   dd |D }t t}|D ]\}}|| | qt| D ]3\}}	| |	}
t| j| |d}|rI|dkr>|
| |O }
|dkrI|
| |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  )r5   rF   r-   r-   r.   r          z0Schema.__apply_nested_option.<locals>.<listcomp>r-   r  r   N)	r   rQ   r(   iterr!   r  r3   r   setattr)r   option_namefield_namesset_operationnested_fieldsnested_optionsrl   nested_namesr   optionsnew_optionsoriginal_optionsr-   r-   r.   __apply_nested_option  s   
zSchema.__apply_nested_optionc                   s  | j jr| | j j}n| | j }|  }| jdur*| | j}||| O }n|}| jr;|| j }|| j| O }|rJd|  d| d}t||  }|D ]}| j| }| 	|| |||< qP|  |  }}	|
 D ]\}}|jsz|||< |js||	|< qodd |	
 D  t tt kr fdd D }
td	t|
 d
d |
 D tttkṙfddD }tdt| || _|	| _|| _dS )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   c                 S  s$   g | ]\}}|j d ur|j n|qS r[   r   )r5   rF   r   r-   r-   r.   r     r   z'Schema._init_fields.<locals>.<listcomp>c                      h | ]}  |d kr|qS r  countr5   x)dump_data_keysr-   r.   r         z&Schema._init_fields.<locals>.<setcomp>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: c                 S  s   g | ]	\}}|j p
|qS r-   )r   )r5   rF   r   r-   r-   r.   r     r   c                   r  r  r  r  )load_attributesr-   r.   r     r  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: )rC   r
   r  r   keysr   rx   r   r   _bind_fieldr!   r   r~   r   r   rQ   r   r   )r   available_field_namesinvalid_fieldsr  messagefields_dictr+   r   r   r   data_keys_duplicatesattributes_duplicatesr-   )r  r  r.   r     sf   






zSchema._init_fieldsr+   r   r   c                 C  r   )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_field  s   zSchema.on_bind_fieldc                 C  s<   || j v rd|_ || jv rd|_|||  | || dS )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>`.
        TN)r~   r   _bind_to_schemar(  r'  r-   r-   r.   r   "  s   

zSchema._bind_field)r   ro   c                C  s(   | j |d|||d}| j |d|||dS )NF)r   r   rb   r   T_invoke_processors)r   ro   r   rb   r   r-   r-   r.   r   0  s   
zSchema._invoke_dump_processorsc             	   C  s0   | j |d|||||d}| j |d|||||dS )NT)r   r   rb   r   r   r   Fr*  )r   ro   r   rb   r   r   r   r-   r-   r.   r   A  s$   	zSchema._invoke_load_processorsc                C  sf  | j t D ]\}}}t| |}|d }|D ]}	z| j|	 }
W n  ty> } z|	| jv r1W Y d }~qtd|	 d|d }~ww |
jd urG|
jn|	}tj	||d}|rt
|D ]1\}}z	||
jp`|	 }W n	 tyl   Y qVw | j||||| jjry|nd d}|tu r||	d  qVqz	||
jp|	 }W n	 ty   Y qw | j||||d}|tu r||	d  qqd S )Nr  "z" field does not exist.r   r   )r   r   r+   r   )r_   r   r3   r
   rg   r   r   r   r;   r   r   r   r   rC   r}   r   pop)r   r   r   rb   re   rW   validator_kwargs	validatorr  r+   r   r   r   do_validater   itemr   validated_valuer-   r-   r.   r   `  sb   

zSchema._invoke_field_validators)r   r   r   c                C  s   | j t D ]J\}	}
}|
|krqt| |	}|r|d rq|dd}|rB|sBtt||D ]\}\}}| j|||||||||d	 q,q| j||||||||d qd S )Nskip_on_field_errorsr   F)r   r   rb   r   r   r   r   )r   r   rb   r   r   r   )r_   r   r3   rN   r   zipr   )r   r   r   r   r   rb   r   r   r   re   	hook_manyr.  r/  r   r   r1  origr-   r-   r.   r     s@   
z Schema._invoke_schema_validatorsc                  s   | j | D ]N\}}}	||krqt| ||	dd}
r;|s;|
r/ fddt||D }q fdd|D }q|
rI||fdi }q|fdi }q|S )Nr   Fc                   s&   g | ]\}}||fd i qS r   r-   )r5   r1  originalrc   rb   	processorr-   r.   r     s    z-Schema._invoke_processors.<locals>.<listcomp>c                   s    g | ]}|fd i qS r   r-   )r5   r1  r8  r-   r.   r     r	  rb   )r_   r3   rN   r   )r   ro   r   r   rb   r   rc   re   r5  processor_kwargsr   r-   r8  r.   r+    s   

zSchema._invoke_processors)r   r   rx   r   rb   r   r~   r   r   r   r   r   r   r   )r   rG   )r
   rE   rF   rG   r   r   )r   r   r   rB   rb   r   )r   rB   rm   rG   r   rB   )r   rB   rb   r   )r   rB   rb   r   )
r   r   r   r   rb   r   r   r   r   r   )r   r   rb   r   r   r   r   r   )r   r   rb   r   r   r   r   r   )r   r   r   r   rb   r   r   r   r   r   r   r   r   r   )r   r   rb   r   r   r   r   r   )
r   r   rb   r   r   r   r   r   r   r   )r   r   )r+   rG   r   r   r   r   )ro   rG   rb   r   )
ro   rG   r   r   rb   r   r   r   r   r   )r   r   rb   r   )r   r   r   r   rb   r   r   r   r   r   r   r   )ro   rG   r   r   r   r   rb   r   )Hr'   rq   rr   rs   rG   r%   StringbytesdtdatetimeDateTimefloatFloatr   Booleanr   RawrQ   r   intIntegeruuidUUIDtimeTimedateDate	timedelta	TimeDeltadecimalDecimalr   rt   r   r   rw   rD   r   r  rT   r   r2   r_   rA   r\   r   ru   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   
 6]
*
 

!s$..
h


I


;4r   )	metaclass)r   r    )r0   r1   )=rs   
__future__r   r   r>  r=  rN  r;   r9   r   r=   r   rF  abcr   collectionsr   collections.abcr   r   	itertoolsr   marshmallowr   r	   r
   r%   marshmallow.constantsr   r   r   r   marshmallow.decoratorsr   r   r   r   r   r   marshmallow.error_storer   marshmallow.exceptionsr   r   r   marshmallow.orderedsetr   marshmallow.utilsr   r   r   r   TYPE_CHECKINGmarshmallow.fieldsr   r/   r@   r1   rw   r   
BaseSchemar-   r-   r-   r.   <module>   sN     

q        