
    8'h6                       d Z ddlm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 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mZmZ er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(  G d de      Z)d$dZ* e	d      d%d       Z+d&dZ,dd	 	 	 	 	 	 	 	 	 	 	 d'dZ-d(dZ.d)dZ/ddd 	 	 	 	 	 	 	 	 	 d*d!Z0d+d"Z1d+d#Z2y),zmPrivate logic related to fields (the `Field()` function and `FieldInfo` class), and arguments to `Annotated`.    )annotationsN)copy)	lru_cache)TYPE_CHECKINGAny)PydanticUndefined)PydanticUserError   )_typing_extra)ConfigWrapper)extract_docstrings_from_cls)import_cached_base_modelimport_cached_field_info)Representation)get_cls_type_hints_lenientis_classvaris_finalvarBaseMetadata   )	FieldInfo)	BaseModel)StandardDataclass)DecoratorInfosc                      e Zd ZdZdZy)PydanticMetadataz0Base class for annotation markers like `Strict`. N)__name__
__module____qualname____doc__	__slots__r       V/var/www/html/trade_iq/venv/lib/python3.12/site-packages/pydantic/_internal/_fields.pyr   r       s
    :Ir#   r   c                 "     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)metadatas    r$   pydantic_general_metadatar(   &   s     # "8,,r#   )maxsizec                 2    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y)7_general_metadata_cls.<locals>._PydanticGeneralMetadataz,Pydantic general metadata like `max_digits`.c                    || _         y N)__dict__)selfr'   s     r$   __init__z@_general_metadata_cls.<locals>._PydanticGeneralMetadata.__init__:   s	    $DMr#   N)r'   r   )r   r   r    r!   r1   r   r#   r$   _PydanticGeneralMetadatar,   7   s
    :	%r#   r2   )annotated_typesr   r   )r   r2   s     r$   r&   r&   2   s     -%#3\ % $#r#   c                    |j                   r@t        |       }|j                         D ]!  \  }}|j                  ||v s||   |_        # y y r.   )use_attribute_docstringsr   itemsdescription)clsfieldsconfig_wrapperfields_docsann_name
field_infos         r$   _update_fields_from_docstringsr>   @   sT    ..1#6$*LLN 	? Hj%%-(k2I)4X)>
&	? /r#   )typevars_mapc               @   t               }t               }t        | |      }| j                  j	                  di       }i }	t               }
|j                         D ]v  \  }dk(  r|j                  D ]  }j                  |      s|D ]H  }t        |      st        ||      r|j                  v r+t        d dt        |       d| d       t        fd|j                  D              }t        j                   d d| j"                   d	| d
| d	t$                t'        |      r|
j)                         t+        |t        | t,                    r|
j)                         t/              s$| j0                  rdk7  rt        dd      t        | di       j	                  d      }|D ]  }t3        j4                  |      rt3        j6                  |      ndD ch c]  }|j8                   }}t        |      sS||u rX|v r]|vrbt        j                   d d| j:                   d|j:                   dt$                	 t        | t,              }|t,        u rt<        	 t?        |       |jA                  ||      }	 tC        |        | j                  d   }|jL                  v rtO        d      ||	<   y |r'|	jQ                         D ]  }|jS                  ||        tU        | |	|       |	|
fS c c}w # t<        $ r Y zw xY w# t<        $ rr |v r|jE                  |      }nYi }| jF                  ddd   D ]  }|jI                  t        |di                |v rtK        |         }n|jE                  |      }Y w xY w)a[  Collect the fields of a nascent pydantic model.

    Also collect the names of any ClassVars present in the type hints.

    The returned value is a tuple of two items: the fields dict, and the set of ClassVar names.

    Args:
        cls: BaseModel or dataclass.
        bases: Parents of the class, generally `cls.__bases__`.
        config_wrapper: The config wrapper instance.
        types_namespace: Optional extra namespace to look for types in.
        typevars_map: A dictionary mapping type variables to their concrete types.

    Returns:
        A tuple contains fields and class variables.

    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.
    __annotations__model_configzField "z" conflicts with member z of protected namespace "z".c              3  F   K   | ]  }j                  |      r|  y wr.   
startswith).0xr<   s     r$   	<genexpr>z'collect_model_fields.<locals>.<genexpr>   s$      -hNaNabcNd-s   !!z" in z( has conflict with protected namespace "z_".

You may be able to resolve this warning by setting `model_config['protected_namespaces'] = z`.rootzUnexpected field with name z4; only 'root' is allowed as a field of a `RootModel`__pydantic_generic_metadata__originr   zField name "z" in "z"" shadows an attribute in parent ""Nmodel_fields__pydantic_decorators__z0you can't override a field with a computed field)+r   r   r   r/   getsetr6   protected_namespacesrE   hasattr
issubclassrN   	NameErrorgetattrtuplewarningswarnr   UserWarningr   add_is_finalvar_with_default_valr   is_valid_field_name__pydantic_root_model__dataclassesis_dataclassr9   namer    AttributeError#_warn_on_nested_alias_in_annotationfrom_annotated_attributedelattrfrom_annotation	__bases__updater   computed_fields
ValueErrorvaluesapply_typevars_mapr>   )r8   basesr:   types_namespacer?   r   
FieldInfo_
type_hintsr   r9   
class_varsann_typeprotected_namespacebvalid_namespacesgeneric_originbasefielddataclass_fieldsdefaultr=   model_fields_lookuprG   
decoratorsr<   s                           @r$   collect_model_fieldsr}   H   s#   < )*I)+J+CAJ ,,""#4b9K#%F5J(..0 g&(~% #1#F#F 	""#67 Aq(+ *1i 8X=W"+")(3KGTUW_L`Ka";<O;PPR!T#  (- -#1#F#F- ($ MM!(5>fgzf{ |DDTCUUWY $		& x NN8$(73J[3\]NN8$"8,&&8v+=-h\9mn  !&ErJNNxX 	DEPE]E]^bEc););D)Aik $

    tX&>)// ;."8*F33C3C2D E))*!-%	0	c8->?G++$$ ,* 0(C#<<XwOJX& &)\\2K%L
z111OPP%xOg&R ]]_ 	DE$$\?C	D #3?:K j " 5  	F;&'77A
 =?#tt, OA'..wq."/MNO22 "&&9(&C!DJ
 ",!;!;H!EJ#	Fs+   -LL"L	LL"A8NNc                   t               }t        | dd       }|rr|D ]l  }t        j                  |      st        j                  |      D ]<  }t        ||      s|j                  t        j                  d| dt                 y  n y y )N__args__z `alias` specification on field "z5" must be set on outermost annotation to take effect.)
r   rV   r   is_annotatedget_args
isinstancealiasrX   rY   rZ   )rr   r<   r   argsanno_arganno_type_args         r$   rc   rc      s    (*I8Z.D 	H))(3%2%;%;H%E M!-;@S@S@_ >xjH}~' 	 r#   c                    t               }t        |       sy|t        u ryt        ||      r|j                  t        u r|j
                  yy)NFT)r   r   r   r   rz   default_factory)type_valr   s      r$   r\   r\      sH    (*Iu	!	!	C	#8I)IcNaNaNir#   )r?   r:   c                  t               }i }| j                  }t        t        |             }t        j
                  j                  | j                        }|i |j                  |xs i }|j                         D ]H  \  }	}
t        j                  |
j                  ||      }t        |      r4|
j                  s;|
j                  t         j"                  k(  r|
j$                  t         j"                  k(  r{t'        |
j                  |      r]|
j                  j(                  r*|
j                  j                  du rt+        d|	 dd      |j-                  ||
j                        }n|j-                  ||
      }|||	<   |j                  t.        ust'        t1        | |	|      |      s2t3        | |	|j                         K |r'|j5                         D ]  }|j7                  ||        |t9        | ||       |S )aF  Collect the fields of a dataclass.

    Args:
        cls: dataclass.
        types_namespace: Optional extra namespace to look for types in.
        typevars_map: A dictionary mapping type variables to their concrete types.
        config_wrapper: The config wrapper instance.

    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)code)r   __dataclass_fields__dictvarssysmodulesrP   r   r/   r6   r   eval_type_lenienttyper   initrz   r_   MISSINGr   r   init_varr	   rd   r   rV   setattrrk   rl   r>   )r8   rn   r?   r:   ro   r9   ry   cls_localnssource_moduler<   dataclass_fieldrr   r=   rx   s                 r$   collect_dataclass_fieldsr      s   $ *+J#%F585M5MtCy/KKKOOCNN3M O]33O8M2O%5%;%;%=  7!/ 22?3G3GZefx   $$'';+>+>>//;3F3FF o--z:&&//"**//58+*8*4xy9  #<<XG^G^_J#<<XWJ%x%66:gcS[]gFhjt;uC:#5#56A 7D ]]_ 	DE$$\?C	D !&sFNCMr#   c                &    | j                  d       S )N_rD   ra   s    r$   r]   r]   H  s    s###r#   c                L    | j                  d      xr | j                  d       S )Nr   __rD   r   s    r$   is_valid_privateattr_namer   L  s"    ??3=(=$==r#   )r'   r   returnr   )r   ztype[BaseMetadata])r8   	type[Any]r9   dict[str, FieldInfo]r:   r   r   None)r8   ztype[BaseModel]rm   ztuple[type[Any], ...]r:   r   rn   dict[str, Any] | Noner?   dict[Any, Any] | Noner   z%tuple[dict[str, FieldInfo], set[str]])rr   r   r<   strr   r   )r   r   r   r   r   bool)
r8   ztype[StandardDataclass]rn   r   r?   r   r:   zConfigWrapper | Noner   r   )ra   r   r   r   )3r!   
__future__r   _annotationsr_   r   rX   r   	functoolsr   typingr   r   pydantic_corer   pydantic.errorsr	    r   _configr   _docs_extractionr   _import_utilsr   r   _reprr   r   r   r   r3   r   r9   r   mainr   _dataclassesr   _decoratorsr   r   r(   r&   r>   r}   rc   r\   r   r]   r   r   r#   r$   <module>r      s   s 2  
    % + -  " 9 M ! O O," /+~ 	- 4
$ 
$? +/X	X X "X +	X (X +Xv 
" +/+/E	 E*E (	E
 )E EP$>r#   