
    iE{                       d Z ddlm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mZmZmZ dd	lmZ dd
lmZ ddlmZ ddlm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' ddl(m)Z)m*Z* ddl+m,Z, ddl-m.Z. ddl/m0Z0 ddl1m2Z2m3Z3 er ddl4m5Z5 ddl6m7Z7 ddl8m9Z9 ddl:m;Z;m<Z< ddl=m>Z>  G d de0          Z? ej@        dji e, G d  d!                      ZAdkd&ZBe	dld(            ZCdmd1ZDdndod9ZEdpd?ZFdqdBZGdrdEZHh dFZIh dGZJddHdsdOZKdtdRZLdudTZMdddUdvdYZNdwd[ZOdxd]ZPdxd^ZQdydbZRdd2dcdzdiZSdS ){zmPrivate logic related to fields (the `Field()` function and `FieldInfo` class), and arguments to `Annotated`.    )annotationsN)Mapping)cache)	Parameterismethoddescriptor)Pattern)TYPE_CHECKINGAnyCallableTypeVarcast)PydanticUndefined)TypeIs)AnnotationSource)PydanticDeprecatedSince211)PydanticUserError   )AliasGenerator   )	_generics_typing_extra)ConfigWrapper)extract_docstrings_from_cls)import_cached_base_modelimport_cached_field_info)
slots_true)
NsResolver)Representation)can_be_positionalget_first_not_noneBaseMetadata)	FieldInfo)	BaseModel)PydanticDataclassStandardDataclass)DecoratorInfosc                      e Zd ZdZdZdS )PydanticMetadataz0Base class for annotation markers like `Strict`. N)__name__
__module____qualname____doc__	__slots__r*       `/var/www/html/crypto-bot/backend/venv/lib/python3.11/site-packages/pydantic/_internal/_fields.pyr)   r)   '   s        ::IIIr0   r)   c                  $    e Zd ZU ded<   ded<   dS )PydanticExtraInfor
   
annotationboolcompleteN)r+   r,   r-   __annotations__r*   r0   r1   r3   r3   -   s$          OOONNNNNr0   r3   metadatar
   returnr"   c                 0     t                      |           S )zCreate a new `_PydanticGeneralMetadata` class with the given metadata.

    Args:
        **metadata: The metadata to add.

    Returns:
        The new `_PydanticGeneralMetadata` class.
    )_general_metadata_cls)r8   s    r1   pydantic_general_metadatar<   4   s     # ""8,,,r0   type[BaseMetadata]c                 :    ddl m}   G d dt          |           }|S )zCDo it this way to avoid importing `annotated_types` at import time.r   r!   c                      e Zd ZdZddZdS )7_general_metadata_cls.<locals>._PydanticGeneralMetadataz,Pydantic general metadata like `max_digits`.r8   r
   c                    || _         d S N)__dict__)selfr8   s     r1   __init__z@_general_metadata_cls.<locals>._PydanticGeneralMetadata.__init__H   s    $DMMMr0   N)r8   r
   )r+   r,   r-   r.   rE   r*   r0   r1   _PydanticGeneralMetadatar@   E   s.        ::	% 	% 	% 	% 	% 	%r0   rF   )annotated_typesr"   r)   )r"   rF   s     r1   r;   r;   @   sK     -,,,,,% % % % %#3\ % % % $#r0   protected_namespacestuple[str | Pattern[str], ...]ann_namestrbasestuple[type[Any], ...]cls_nameNonec                R   t                      }| D ]}d}t          |t                    r|                    |          d u}n*t          |t                    r|                    |          }|r5|D ]\}t          ||          rJt          ||          r|t          |di           v s't          d|dt          ||           d|d          ]g }| D ]y}	t          |	t                    r4|	                    |          s|
                    d|	j        d           K|                    |	          s|
                    d	|	 d	           zd
d                    |           t          |          dk    rdnd }
t          j        d|d|d|d|
 d	t           d           d S )NF__pydantic_fields__Field z conflicts with member z of protected namespace .zre.compile()'(z, r   z,)z in z$ conflicts with protected namespace zX.

You may be able to solve this by setting the 'protected_namespaces' configuration to    
stacklevel)r   
isinstancer   matchrK   
startswithhasattr
issubclassgetattr
ValueErrorappendpatternjoinlenwarningswarnUserWarning)rH   rJ   rL   rN   r$   protected_namespacens_violationbvalid_namespacespnvalid_namespaces_strs              r1   _check_protected_namespacesrn   N   se    )**I3    )733 	D.44X>>dJLL+S11 	D#../BCCL 	  1h'' &q)44 WQPegiEjEj9j9j(PX P PPQS[H\H\ P P7JP P P  
 /1 . ? ?B!"g.. ?!xx11 S,334Q"*4Q4Q4QRRR'22266 ?,33IIII>>>'u4995E+F+F'uPSTdPePeijPjPjps'u'u$DX D DX D D]p D D mAD D D 	   7   r0   Fcls	type[Any]fieldsdict[str, FieldInfo]use_inspectr5   c                    t          | |          }|                                D ]\  }}|j        ||v r||         |_        d S )Nrs   )r   itemsdescription)ro   rq   rs   fields_docsrJ   
field_infos         r1   _update_fields_from_docstringsrz   y   s[    -c{KKKK & ; ;*!)h+.E.E%0%:J"; ;r0   title_generatorCallable[[str, FieldInfo], str]
field_namery   r#   c                    |j         D | ||          }t          |t                    st          d|  d|j                   ||_         d S d S )Nzfield_title_generator  must return str, not )titlerZ   rK   	TypeError	__class__)r{   r}   ry   r   s       r1   *_apply_field_title_generator_to_field_infor      sj    
 
J77%%% 	om_mm\a\kmmnnn 
  r0   alias_generator%Callable[[str], str] | AliasGeneratorc                   |j         !|j         dk    s|j        |j        |j        d\  }}}t	          | t
                    r|                     |          \  }}}nIt          |           r: | |          }t	          |t                    st          d|  d|j
                   |j         |j         dk    rd|_         |j         dk    r1t          ||          |_        t          ||          |_        ||_        |j        ||_        |j        t          ||          |_        |j        t          ||          |_        dS dS dS )av  Apply an alias generator to aliases on a `FieldInfo` instance if appropriate.

    Args:
        alias_generator: A callable that takes a string and returns a string, or an `AliasGenerator` instance.
        field_name: The name of the field from which to generate the alias.
        field_info: The `FieldInfo` instance to which the alias generator is (maybe) applied.
    Nr   )NNNzalias_generator r   )alias_priorityaliasvalidation_aliasserialization_aliasrZ   r   generate_aliasescallablerK   r   r   r    )r   r}   ry   r   r   r   s         r1   $_apply_alias_generator_to_field_infor      s    	!)$))#&.)17G4!4o~66 	m;J;[;[\f;g;g8E#%8%8o&& 	m#OJ//EeS)) m k? k kZ_Zi k klll
 $,
0IQ0N0N()J% $))-?@SUZ-[-[J**<=Mu*U*UJ'$J #$J)1-?@SUZ-[-[J*&.*<=Mu*U*UJ'''; 218 /.r0   config_wrapperr   c                    |j         p| j         }|t          |||           | j        t          | j        ||           dS dS )ap  Update the `FieldInfo` instance from the configuration set on the model it belongs to.

    This will apply the title and alias generators from the configuration.

    Args:
        config_wrapper: The configuration from the model.
        field_name: The field name the `FieldInfo` instance is attached to.
        field_info: The `FieldInfo` instance to update.
    N)field_title_generatorr   r   r   )r   r}   ry   r   s       r1   update_field_from_configr      s\     '<d@d(23H*V`aaa%1,^-KZYcddddd 21r0   >   copydictjson_iter_calculate_keys_copy_and_set_values>
   schemafrom_ormvalidate	construct	parse_obj	parse_raw
_get_value
parse_fileschema_jsonupdate_forward_refs)typevars_maptype[BaseModel]ns_resolverr   r   Mapping[TypeVar, Any] | None?tuple[dict[str, FieldInfo], PydanticExtraInfo | None, set[str]]c                  t                      }t                      | j        }i }t          |          D ]*}t	          |dd          x}r|                    |           +t          j        | |          }	t          j        |           }
i }t                      }|	
                                D ]x\  }\  }}|dk    rt          |j        ||| j                   t          j        |          r|                    |           Wt	          | |t                     t           urYt#          fdt$          D                       s1t'          d          r(t#          fdt(          D                       rt           t+          |          s| j        r|d	k    rt/          d
|d          |D ]}t'          ||          r||
vrt	          | di                               d          }||u r@d t3          j        |          rt3          j        |          ndD             }||v ryt9          j        d| d| j         d|j         dt>          d           t           u rp||
v s||vr3|                     |tB          j"                  }||_#        |sd|_$        n;||         %                                }|rtM          |||d          }n
|}ntO          |          r@tQ          j)                  r,j)        *                    d|           }|_)        |j+        d<   |,                    |tB          j"                  }|_-        ||_#        |sd|_$        nZd|j.        v rQ|/                                s=t9          j        d|d|d|dt`          d            |                    |           	 tc          | |           n# td          $ r Y nw xY w| j3        d!         }||j4        v rtk          d"|d#| j        d$          |||<   |j$        rtm          |||           z|j7        rtq          | |           d}d%|	v r|	d%         \  }}ts          ||&          }|||fS )'a  Collect the fields and class variables names of a nascent Pydantic model.

    The fields collection process is *lenient*, meaning it won't error if string annotations
    fail to evaluate. If this happens, the original annotation (and assigned value, if any)
    is stored on the created `FieldInfo` instance.

    The `rebuild_model_fields()` should be called at a later point (e.g. when rebuilding the model),
    and will make use of these stored attributes.

    Args:
        cls: BaseModel or dataclass.
        config_wrapper: The config wrapper instance.
        ns_resolver: Namespace resolver to use when getting model annotations.
        typevars_map: A dictionary mapping type variables to their concrete types.

    Returns:
        A three-tuple containing the model fields, the `PydanticExtraInfo` instance if the `__pydantic_extra__` annotation is set,
        and class variables names.

    Raises:
        NameError:
            - If there is a conflict between a field name and protected namespaces.
            - If there is a field other than `root` in `RootModel`.
            - If a field shadows an attribute in the parent model.
    rQ   N)r   model_config)rH   rJ   rL   rN   c              3  >   K   | ]}t          |d           u V  d S rB   )r_   .0	depr_name
BaseModel_assigned_values     r1   	<genexpr>z'collect_model_fields.<locals>.<genexpr>&  s4      qq9
It44Fqqqqqqr0   __func__c              3  f   K   | ]+}t          t          |d           dd           j        u V  ,d S )Nr   )r_   r   r   s     r1   r   z'collect_model_fields.<locals>.<genexpr>*  sX        ! GJ	4@@*dSSWeWnn     r0   rootzUnexpected field with name z4; only 'root' is allowed as a field of a `RootModel`__pydantic_generic_metadata__originc                    h | ]	}|j         
S r*   name)r   fields     r1   	<setcomp>z'collect_model_fields.<locals>.<setcomp>G  s'     $ $ $#(EJ$ $ $r0   r*   zField name "z" in "z"" shadows an attribute in parent ""   rX   _sourceFTr   r   lenientdefaultfinalzAnnotation z= is marked as final and has a default value. Pydantic treats zz as a class variable, but it will be considered as a normal field in V3 to be aligned with dataclasses. If you still want zV to be considered as a class variable, annotate it as: `ClassVar[<type>] = <default>.`)categoryrY   __pydantic_decorators__rR   z
 of class zf overrides symbol of same name in a parent class. This override with a computed_field is incompatible.__pydantic_extra__r4   r6   ):r   r   	__bases__reversedr_   updater   get_model_type_hintssafe_get_annotationssetrv   rn   rH   r+   is_classvar_annotationaddr   any_deprecated_method_namesr]   _deprecated_classmethod_namesis_valid_field_name__pydantic_root_model__	NameErrorgetdataclassesis_dataclassrq   re   rf   r-   rg   from_annotationr   CLASS_original_annotation	_complete_copy_recreate_field_inforZ   r   r   __get___attributes_setfrom_annotated_attribute_original_assignment_qualifiersis_requiredr   delattrAttributeErrorrC   computed_fieldsr   r   use_attribute_docstringsrz   r3   )ro   r   r   r   
FieldInfo_rL   parent_fields_lookupbasemodel_fields
type_hintscls_annotationsrq   
class_varsrJ   ann_type	evaluatedgeneric_origindataclass_fieldsry   parent_field_infor   
decoratorspydantic_extra_infoannr6   r   r   s                            @@r1   collect_model_fieldsr      s   @ *++J)++JME13 6 6"4)>EEE< 	6 ''5553C[QQQJ $8==O#%F55J+5+;+;+=+= SK SK''8Y~%% #!/!D\		
 	
 	
 	
 /99 	NN8$$$ h0ABB!222qqqqqXpqqqqq 3
 
33 3      %B     3 /N"8,, 	& 	8v+=+=nhnnn    	 	DtX&& ?22 ").Mr!R!R!V!VW_!`!`>))$ $ITIabfIgIg-o[-?-E-E-Emo$ $ $  /// -8 - -33C - -)- - - 	    ...?**h>R.R.R (77JZJ`7aa
2:
/  1+0J(
 %9$B$H$H$J$J!   3!5){Q]gk" " "JJ "3JJ .*55 D:L^Mc:d:d D )088sCC)0&<C.y9#<<X~_o_u<vvJ /=J+.6J+ ',
$$J222:;Q;Q;S;S2E( E Eks E E"*E E E 8     x(((
X&&&&!   
 &)\2K%L
z111G G Gs| G G G   &x 	K$^XzJJJ. 4&sF33348z))"#78X/
 
 

 &
22s   9O


OOMapping[TypeVar, Any]5tuple[dict[str, FieldInfo], PydanticExtraInfo | None]c                  i }|                     |           5  | j                                        D ];\  }}|j        r|||<   t	          |||d          }t          |||           |||<   <| j        =| j        j        s1t          t          j
        | j        j        g|j        R  d          }n| j        }ddd           n# 1 swxY w Y   ||fS )a^  Rebuild the (already present) model fields by trying to reevaluate annotations.

    This function should be called whenever a model with incomplete fields is encountered.

    Returns:
        A two-tuple, the first element being the rebuilt fields, the second element being
        the rebuild `PydanticExtraInfo` instance, if available.

    Raises:
        NameError: If one of the annotations failed to evaluate.

    Note:
        This function *doesn't* mutate the model fields in place, as it can be called during
        schema generation, where you don't want to mutate other model's fields.
    Fr   NTr   )pushrQ   rv   r   r   r   __pydantic_extra_info__r6   r3   r   	eval_typer4   types_namespace)	ro   r   r   r   rebuilt_fieldsf_namery   	new_fieldrebuilt_extra_infos	            r1   rebuild_model_fieldsr    s_   , ,.N			#		 = ="%"9"?"?"A"A 	3 	3FJ# 3)3v&&0Kl\a  	 )KKK)2v&&&23;V;_2!2(2/:=H=X   	" " " "%!<'= = = = = = = = = = = = = = =* ---s   B!CC	C	r   c               2   t                      }| j        }|r5t          j        | j        |          }t          j        |g|j        R  \  }}nJt          j        | j        g|j        R  }t          j        ||          }t          j        |g|j        R  }d}| j	        x}t          u r"|                    |t          j                  }	n)|                    ||t          j                  }	||	_	        ||	_        |	j        |	j        n||	_        |sd|	_        |	S )NTr   F)r   rw   r   replace_typesr   r   try_eval_typer   r   r   r   r   r   r   r   r   )
ry   r   r   r   r   existing_descr   r   assignr   s
             r1   r   r     sX    *++J*M %j&E|TT&4
(
 
 
YY %+
(
 
 
 %c<88%
(
 
 
 	116GGG..s<L<R.SS		77VM]Mc7dd	)/	&%(I"5>5J5VI11\iI $#	r0   )r   r   type[StandardDataclass]NsResolver | Nonedict[Any, Any] | Nonec          
        t                      }i }|pt                      }| j        }t          | j                  D ]}t          j        |          s|                    |          5  |                                D ]\  }}	t          j
        |          }
||
vr|j        \  }}t          j        |	j        ||          \  }}t          j        |          r\|	j        s'|	j        t
          j        u r|	j        t
          j        u rt'          |	j        |          rd|	j        j        r$|	j        j        du rt+          d| dd          |                    ||	j        t.          j                  }|	j        |_        n)|                    ||	t.          j                  }|	|_        |sd|_        ||_        |||<   t9          |||           |j        t:          ur5t'          t=          | ||          |          rt?          | ||j                   	 ddd           n# 1 swxY w Y   |r,|                                 D ]}|!                    |           |j"        r!tG          | |tI          | d           	           |S )
a|  Collect the fields of a dataclass.

    Args:
        cls: dataclass.
        config_wrapper: The config wrapper instance.
        ns_resolver: Namespace resolver to use when getting dataclass annotations.
            Defaults to an empty instance.
        typevars_map: A dictionary mapping type variables to their concrete types.

    Returns:
        The dataclass fields.
    FzDataclass field zD has init=False and init_var=True, but these are mutually exclusive.zclashing-init-and-init-var)coder   N__is_pydantic_dataclass__ru   )%r   r   __dataclass_fields__r   __mro__r   r   r   rv   r   r   r   r  typer   initr   MISSINGdefault_factoryrZ   init_varr   r   r   	DATACLASSr   r   r   r   r   r_   setattrvaluesapply_typevars_mapr   rz   r]   )ro   r   r   r   r   rq   r   r   rJ   dataclass_field	base_annsglobalnslocalnsr   r   ry   r   s                    r1   collect_dataclass_fieldsr    sT   & *++J#%F-K/
 %% ;? ;?'-- 	d## 7	? 7	?-=-C-C-E-E 6? 6?)/)>tDD	9,, $/$?!'&3&A/BVX`bi&j&j#) 7AA  (,'/;3FFF'7;;NNN o5zBB F&.7 !*275@@"3 !B8  !B  !B  !B%A# # #  !!+!D!D /"9CSC] "E " "J 7F6MJ33!+!D!D /;K;U "E " "J 7FJ3  ?+0J(6>J3#-x (:NNN%->>>:C:66
D D> C:+=>>>m6?7	? 7	? 7	? 7	? 7	? 7	? 7	? 7	? 7	? 7	? 7	? 7	? 7	? 7	? 7	?r  3]]__ 	3 	3E $$\2222. 
& $C)DEEE	
 	
 	
 	
 Ms   )F,H""H&	)H&	type[PydanticDataclass]c                  t                      }i }|                    |           5  | j                                        D ]\  }}|j        r|||<   |j        }t          j        |j        g|j	        R  }	t          j        |	|          }	|                    |	|j        t          j                  }
|
j        |
j        n||
_        t!          |||
           |
||<   	 ddd           n# 1 swxY w Y   |S )a  Rebuild the (already present) dataclass fields by trying to reevaluate annotations.

    This function should be called whenever a dataclass with incomplete fields is encountered.

    Raises:
        NameError: If one of the annotations failed to evaluate.

    Note:
        This function *doesn't* mutate the dataclass fields in place, as it can be called during
        schema generation, where you don't want to mutate other dataclass's fields.
    r   N)r   r   rQ   rv   r   rw   r   r   r   r   r   r  r   r   r   r  r   )ro   r   r   r   r   r   r   ry   r  r   r   s              r1   rebuild_dataclass_fieldsr   {  so   $ *++J+-N			#		 3 3"%"9"?"?"A"A 	3 	3FJ# 3)3v&& * 6#-3 0    -c<@@&??3,6 @  	 BKAVAb	(=(=hu	%(KKK)2v&&'	33 3 3 3 3 3 3 3 3 3 3 3 3 3 3, s   B7C**C.1C.r   c                .    |                      d           S )N_r\   r   s    r1   r   r     s    s####r0   c                X    |                      d          o|                      d           S )Nr"  __r#  r   s    r1   is_valid_privateattr_namer&    s(    ??3=(=(=$==r0   r  3Callable[[], Any] | Callable[[dict[str, Any]], Any]'TypeIs[Callable[[dict[str, Any]], Any]]c                ,   	 t          j        |           }n# t          t          f$ r Y dS w xY wt	          |j                                                  }t          |          dk    o-t          |d                   o|d         j	        t          j        u S )zMWhether the provided default factory callable has a validated data parameter.Fr   r   )r   signature_no_evalr`   r   list
parametersr  rd   r   r   r   empty)r  sigr,  s      r1   takes_validated_data_argumentr/    s    -o>>	"    uu
 cn++--..Jz??aq$5jm$D$DqTUI^bkbqIqqs    ,,)validated_datacall_default_factoryr   :Callable[[], Any] | Callable[[dict[str, Any]], Any] | Noner0  dict[str, Any] | Noner1  c                   ddl m} | ||           S |rVt          |          r,t          d|          }|t	          d           ||          S t          d|          } |            S t
          S )zMResolve the default value using either a static default or a default_factory.r   )smart_deepcopyN)r  zCallable[[dict[str, Any]], Any]zpThe default factory requires the 'validated_data' argument, which was not provided when calling 'get_default()'.zCallable[[], Any])_utilsr5  r/  r   r`   r   )r   r  r0  r1  r5  facs         r1   resolve_default_valuer8    s     '&&&&&~g&&& 
(III 		8/JJC%  G   3~&&&*O<<C355Lr0   r*   )r8   r
   r9   r"   )r9   r=   )
rH   rI   rJ   rK   rL   rM   rN   rK   r9   rO   )F)ro   rp   rq   rr   rs   r5   r9   rO   )r{   r|   r}   rK   ry   r#   )r   r   r}   rK   ry   r#   )r   r   r}   rK   ry   r#   r9   rO   )
ro   r   r   r   r   r   r   r   r9   r   )
ro   r   r   r   r   r   r   r   r9   r   )
ry   r#   r   r   r   r   r   r5   r9   r#   )
ro   r  r   r   r   r	  r   r
  r9   rr   )
ro   r  r   r   r   r   r   r   r9   rr   )r   rK   r9   r5   )r  r'  r9   r(  )
r   r
   r  r2  r0  r3  r1  r5   r9   r
   )Tr.   
__future__r   _annotationsr   re   collections.abcr   	functoolsr   inspectr   r   rer   typingr	   r
   r   r   r   pydantic_corer   typing_extensionsr   typing_inspection.introspectionr   pydanticr   pydantic.errorsr   aliasesr    r   r   _configr   _docs_extractionr   _import_utilsr   r   _internal_dataclassr   _namespace_utilsr   _reprr   r6  r   r    rG   r"   rq   r#   mainr$   _dataclassesr%   r&   _decoratorsr'   r)   	dataclassr3   r<   r;   rn   rz   r   r   r   r   r   r   r  r   r  r   r   r&  r/  r8  r*   r0   r1   <module>rQ     s`   s s 2 2 2 2 2 2      # # # # # #       1 1 1 1 1 1 1 1       > > > > > > > > > > > > > > + + + + + + $ $ $ $ $ $ < < < < < < / / / / / / - - - - - - $ $ $ $ $ $ & & & & & & & & " " " " " " 9 9 9 9 9 9 M M M M M M M M + + + + + + ( ( ( ( ( ( ! ! ! ! ! ! 9 9 9 9 9 9 9 9 ,,,,,,,""""""      BBBBBBBB++++++    ~    $$$$       %$	- 	- 	- 	- 
$ 
$ 
$ 
$( ( ( (V; ; ; ; ;
! 
! 
! 
!/V /V /V /Vde e e e" hgg ! ! ! & 26Q3 Q3 Q3 Q3 Q3 Q3h,. ,. ,. ,.^) ) ) )` &**.i i i i i iX+ + + +\$ $ $ $> > > >r r r r( -1!&       r0   