
    TgB                       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mZ ddl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& 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/m0Z0  G d de$          Z1dHdZ2 ed           dId"            Z3dJd*Z4dd+dKd4Z5dLd8Z6dMd<Z7dddd=dNd@Z8dOdBZ9dOdCZ:dPdGZ;dS )QzmPrivate logic related to fields (the `Field()` function and `FieldInfo` class), and arguments to `Annotated`.    )annotationsN)copy)	lru_cache)	Parameterismethoddescriptor	signature)TYPE_CHECKINGAnyCallablePattern)PydanticUndefined)TypeIs)PydanticUserError   )_typing_extra)ConfigWrapper)extract_docstrings_from_cls)import_cached_base_modelimport_cached_field_info)
NsResolver)Representation)can_be_positionalBaseMetadata   )	FieldInfo)	BaseModel)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"       O/var/www/sysmax/venv/lib/python3.11/site-packages/pydantic/_internal/_fields.pyr!   r!   "   s        ::IIIr(   r!   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)r*   s    r)   pydantic_general_metadatar.   (   s     # ""8,,,r(   )maxsize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`.r*   r
   c                    || _         d S N)__dict__)selfr*   s     r)   __init__z@_general_metadata_cls.<locals>._PydanticGeneralMetadata.__init__<   s    $DMMMr(   N)r*   r
   )r#   r$   r%   r&   r8   r"   r(   r)   _PydanticGeneralMetadatar3   9   s.        ::	% 	% 	% 	% 	% 	%r(   r9   )annotated_typesr   r!   )r   r9   s     r)   r-   r-   4   sK     -,,,,,% % % % %#3\ % % % $#r(   cls	type[Any]fieldsdict[str, FieldInfo]config_wrapperr   Nonec                    |j         rAt          |           }|                                D ]\  }}|j        ||v r||         |_        d S d S r5   )use_attribute_docstringsr   itemsdescription)r;   r=   r?   fields_docsann_name
field_infos         r)   _update_fields_from_docstringsrH   B   sk    . ?1#66$*LLNN 	? 	? Hj%-(k2I2I)4X)>
&	? ?	? 	?r(   )typevars_maptype[BaseModel]basestuple[type[Any], ...]ns_resolverNsResolver | NonerI   dict[Any, Any] | None%tuple[dict[str, FieldInfo], set[str]]c               	   t                      }t                      }i }t          |          D ]*}t          |dd          x}	r|                    |	           +t          j        | |          }
| j                            di           }i }t                      }|

                                D ]\  }\  }}|dk    r|j        D ]J}d}t          |t                    r|                    |          du}n*t          |t                    r|                    |          }|r|D ]\}t#          ||          rJt%          ||          r|t          |di           v s't'          d| dt          ||           d	| d
          ]d}|j        D ]W}t          |t                    r%|                    |          s|d|j         dfz  }<|                    |          s||fz  }Xt+          j        d| d| j         d| d| d	t0                     Lt          j        |          r|                    |           t7          |t          | |t8                              r|                    |           t;          |          s| j        r|dk    rt'          d|d          t          | di                               d          }|D ]}d t?          j         |          rt?          j!        |          ndD             }t#          ||          r=||u rK||v rP||vrUt+          j        d| d| j"         d|j"         dt0                     	 t          | |t8                    }|t8          u rtF          	 tI          ||           t          ||          r4tK          |j&                  r |j&        '                    d|           |_&        |(                    ||          }||_)        	 tU          | |           nw# tF          $ r Y nkw xY w# tF          $ rZ ||v r|+                    |          }||_)        n6||v rtY          ||                   }n|+                    |          }||_)        Y nw xY w| j        d         }||j-        v rt]          d          |||<   |r,|/                                D ]}|0                    |           tc          | ||           ||fS )ab  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.
        ns_resolver: Namespace resolver to use when getting model annotations.
        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.
    __pydantic_fields__N)rM   __annotations__model_configFzField "z" conflicts with member z of protected namespace "z".r"   zre.compile()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__originc                    h | ]	}|j         
S r"   name).0fields     r)   	<setcomp>z'collect_model_fields.<locals>.<setcomp>   s'          $
     r(   zField name "z" in "z"" shadows an attribute in parent ""__pydantic_decorators__z0you can't override a field with a computed field)2r   r   reversedgetattrupdater   get_model_type_hintsr6   getsetrC   protected_namespaces
isinstancer   matchstr
startswithhasattr
issubclass	NameErrorpatternwarningswarnr#   UserWarningis_classvar_annotationadd_is_finalvar_with_default_valr   is_valid_field_name__pydantic_root_model__dataclassesis_dataclassr=   r%   AttributeError#_warn_on_nested_alias_in_annotationr   default__get__from_annotated_attribute	evaluateddelattrfrom_annotationr   computed_fields
ValueErrorvaluesapply_typevars_maprH   )r;   rK   r?   rM   rI   r   
FieldInfo_parent_fields_lookupbasemodel_fields
type_hintsr   r=   
class_varsrF   ann_typer   protected_namespacens_violationbvalid_namespacespngeneric_origindataclass_fieldsr|   rG   
decoratorsr]   s                               r)   collect_model_fieldsr   J   sh   < )**I)++J13 6 6"4)>EEE< 	6 ''5553C[QQQJ ,""#4b99K#%F55J+5+;+;+=+= {& {&''8Y~%% #1#F 	 	!&L-w77 H288BB$N/55 H'223FGG   Aq(++  *1i 8 8 XQRTikmInIn=n=n"+!T( !T !TGTUW_L`L` !T !T<O!T !T !T# # 
 (*$,A : :%b'22 :#%88H#5#5 S 05P2:5P5P5P4R R 0#+#6#6r#:#: : 0RE 9 0MY( Y Y Y Ygz Y YDTY Y Y $	   /99 	NN8$$$(73J[3\3\]] 	NN8$$$"8,, 	& 	8v+=+=nhnnn   !&ErJJNNxXX 	 	D   EPE]^bEcEc)k);D)A)A)Aik      tX&& >))/// ;..-8 - -33C - -)- - -  &	c8->??G+++$$ ,( 0(CCC':.. E3Ego3V3V E
 #*/"9"9$"D"D#<<XwOOJ#,J X&&&&!   C  	5 	5 	5;&&'77AA
'0
$$ 333 "&&:8&D!E!EJJ
 ",!;!;H!E!EJ+4J(!	5L &)\2K%L
z111OPPP%x 3]]__ 	3 	3E$$\2222"3???:s%   &P,O==
P
	P
A!Q10Q1r   rF   rj   c                   t                      }t          | dd           }|ri|D ]h}t          j        |          rPt          j        |          D ];}t          ||          r)|j        "t          j        d| dt                       d S <gd S d S )N__args__z `alias` specification on field "z5" must be set on outermost annotation to take effect.)
r   rb   r   is_annotatedget_argsrh   aliasrp   rq   rr   )r   rF   r   argsanno_arganno_type_args         r)   r{   r{      s    (**I8Z..D 	 	 	H)(33 %2%;H%E%E  M!-;; @S@_ ~x~~~'   	 		 	r(   type_valboolc                    t                      }t          j        |           sdS |t          u rdS t	          ||          r|j        t          u r	|j        dS dS )NFT)r   r   is_finalvarr   rh   r|   default_factory)r   r   r   s      r)   ru   ru     sg    (**I$U++ u	!	!	!u	C	#	# 8I)I)IcNaNiutr(   )rM   rI   r?   type[StandardDataclass]ConfigWrapper | Nonec          
     V   t                      }i }|pt                      }| j        }t          | j                  D ]}t          j        |          s|                    |          5  |                                D ]N\  }}	||j	        
                    di           vr$|j        \  }
}t          j        |	j        |
|          \  }}t          j        |          ra|	j        s'|	j        t
          j        u r|	j        t
          j        u rt)          |	j        |          rL|	j        j        r$|	j        j        du rt-          d| dd          |                    ||	j                  }n|                    ||	          }|||<   |j        t0          ur5t)          t3          | ||          |          rt5          | ||j                   P	 ddd           n# 1 swxY w Y   |r,|                                D ]}|                    |           |t;          | ||           |S )a|  Collect the fields of a dataclass.

    Args:
        cls: dataclass.
        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.
        config_wrapper: The config wrapper instance.

    Returns:
        The dataclass fields.
    rS   FzDataclass field zD has init=False and init_var=True, but these are mutually exclusive.zclashing-init-and-init-var)codeN)r   r   __dataclass_fields__ra   __mro__rx   ry   pushrC   r6   re   types_namespacer   try_eval_typetypers   initr|   MISSINGr   rh   init_varr   r~   r   rb   setattrr   r   rH   )r;   rM   rI   r?   r   r=   r   r   rF   dataclass_fieldglobalnslocalnsr   _rG   r]   s                   r)   collect_dataclass_fieldsr     s   & *++J#%F-K/
 %% .? .?'-- 	d## *	? *	?-=-C-C-E-E )? )?)/4=#4#45F#K#KKK $/$?!'+9/:NPXZabb! 7AA  (,'/;3FFF'7;;NNN o5zBB `&.7 !*275@@"3 !B8  !B  !B  !B%A# # #  !!+!D!DXOf!g!gJJ!+!D!DX!_!_J#-x %->>>:C:66
D D> C:+=>>>S)?*	? *	? *	? *	? *	? *	? *	? *	? *	? *	? *	? *	? *	? *	? *	?X  3]]__ 	3 	3E $$\2222!&sFNCCCMs   )E%GG	"G	r[   c                .    |                      d           S )Nr   rk   rZ   s    r)   rv   rv   s  s    s####r(   c                X    |                      d          o|                      d           S )Nr   __r   rZ   s    r)   is_valid_privateattr_namer   w  s(    ??3=(=(=$==r(   r   3Callable[[], Any] | Callable[[dict[str, Any]], Any]'TypeIs[Callable[[dict[str, Any]], Any]]c                "   	 t          |           }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   r   	TypeErrorlist
parametersr   lenr   r|   r   empty)r   sigr   s      r)   takes_validated_data_argumentr   {  s    ((	"    uu
 cn++--..Jz??aq$5jm$D$DqTUI^bkbqIqqs    '')r*   r
   r+   r   )r+   r0   )r;   r<   r=   r>   r?   r   r+   r@   )r;   rJ   rK   rL   r?   r   rM   rN   rI   rO   r+   rP   )r   r<   rF   rj   r+   r@   )r   r<   r   r
   r+   r   )
r;   r   rM   rN   rI   rO   r?   r   r+   r>   )r[   rj   r+   r   )r   r   r+   r   )<r&   
__future__r   _annotationsrx   rp   r   	functoolsr   inspectr   r   r   typingr	   r
   r   r   pydantic_corer   typing_extensionsr   pydantic.errorsr    r   _configr   _docs_extractionr   _import_utilsr   r   _namespace_utilsr   _reprr   _utilsr   r:   r   r=   r   mainr   _dataclassesr   _decoratorsr   r!   r.   r-   rH   r   r{   ru   r   rv   r   r   r"   r(   r)   <module>r      s   s s 2 2 2 2 2 2                  < < < < < < < < < < 8 8 8 8 8 8 8 8 8 8 8 8 + + + + + + $ $ $ $ $ $ - - - - - -       " " " " " " 9 9 9 9 9 9 M M M M M M M M ( ( ( ( ( ( ! ! ! ! ! ! % % % % % % ,,,,,,,""""""      //////++++++    ~   	- 	- 	- 	- 4
$ 
$ 
$ 
$? ? ? ? +/p p p p p pf    
 
 
 
  &**.+/V V V V V Vr$ $ $ $> > > >r r r r r rr(   