
    bMhZ                       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
 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 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$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/m0Z0 ddl1m2Z2 er ddl3m4Z4 ddl5m6Z6 ddl7m8Z8 ddl9m:Z:m;Z; ddl<m=Z=  G d de0          Z>dOd$Z?e
dPd&            Z@dQdRd/ZAdd0dSd9ZBdTd=ZCdUd@ZDddddAdVdEZEdWdGZFdXdIZGdXdJZHdYdNZIdS )ZzmPrivate logic related to fields (the `Field()` function and `FieldInfo` class), and arguments to `Annotated`.    )annotationsN)Mapping)copy)cache)	Parameterismethoddescriptor	signature)Pattern)TYPE_CHECKINGAnyCallableTypeVar)PydanticUndefined)TypeIs
get_origin)typing_objects)AnnotationSource)PydanticDeprecatedSince211)PydanticUserError   )	_generics_typing_extra)ConfigWrapper)extract_docstrings_from_cls)import_cached_base_modelimport_cached_field_info)
NsResolver)Representation)can_be_positional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*       Z/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/pydantic/_internal/_fields.pyr)   r)   '   s        ::IIIr0   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)r2   s    r1   pydantic_general_metadatar6   -   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`.r2   r   c                    || _         d S )N)__dict__)selfr2   s     r1   __init__z@_general_metadata_cls.<locals>._PydanticGeneralMetadata.__init__A   s    $DMMMr0   N)r2   r   )r+   r,   r-   r.   r>   r*   r0   r1   _PydanticGeneralMetadatar:   >   s.        ::	% 	% 	% 	% 	% 	%r0   r?   )annotated_typesr!   r)   )r!   r?   s     r1   r5   r5   9   sK     -,,,,,% % % % %#3\ % % % $#r0   Fcls	type[Any]fieldsdict[str, FieldInfo]use_inspectboolNonec                    t          | |          }|                                D ]\  }}|j        ||v r||         |_        d S )NrE   )r   itemsdescription)rA   rC   rE   fields_docsann_name
field_infos         r1   _update_fields_from_docstringsrO   G   s[    -c{KKKK & ; ;*!)h+.E.E%0%:J"; ;r0   )typevars_maptype[BaseModel]config_wrapperr   ns_resolverNsResolver | NonerP   Mapping[TypeVar, Any] | None%tuple[dict[str, FieldInfo], set[str]]c               
   t                      }t                      }| j        }i }t          |          D ]*}t	          |dd          x}	r|                    |	           +t          j        | |          }
| j        	                    di           }i }t                      }|
                                D ]B\  }\  }}|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	t2                     Lt          j        |          r|                    |           t	          | |t8                    }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t2                     |t8          u rR||v s||vr3|#                    |tH          j%                  }|sd|_&        ||_'        nItQ          ||                   }n2tS          ||           t          ||          r4tU          |j+                  r |j+        ,                    d|           |_+        |s$t          ||          r|-                                n|}|.                    ||tH          j%                  }||_/        |sd|_&        ||_'        nZd|j0        v rQ|1                                s=t-          j        d|d|d |d!td          d"#           |                    |           	 tg          | |           n# th          $ r Y nw xY w| j        d$         }||j5        v rtm          d%|d&| j        d'          |||<   D|r3|7                                D ]}|j&        r|8                    |           |j9        rtu          | |           ||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 two-tuple containing model fields 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.
    __pydantic_fields__N)rS   __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     r1   	<setcomp>z'collect_model_fields.<locals>.<setcomp>   s'          $
     r0   zField name "z" in "z"" shadows an attribute in parent ""_source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>.`   )category
stacklevel__pydantic_decorators__zField z
 of class zf overrides symbol of same name in a parent class. This override with a computed_field is incompatible.);r   r   	__bases__reversedgetattrupdater   get_model_type_hintsr<   getsetrJ   protected_namespaces
isinstancer
   matchstr
startswithhasattr
issubclass	NameErrorpatternwarningswarnr+   UserWarningis_classvar_annotationaddr   is_valid_field_name__pydantic_root_model__dataclassesis_dataclassrC   r-   from_annotationr   CLASS	_complete_original_annotationr   #_warn_on_nested_alias_in_annotationr   default__get___copyfrom_annotated_attribute_original_assignment_qualifiersis_requiredr   delattrAttributeErrorcomputed_fields	TypeErrorvaluesapply_typevars_mapuse_attribute_docstringsrO   )rA   rR   rS   rP   r$   
FieldInfo_basesparent_fields_lookupbasemodel_fields
type_hintsr   rC   
class_varsrM   ann_type	evaluatedprotected_namespacens_violationbvalid_namespacespnassigned_valuegeneric_origindataclass_fieldsrN   original_assignment
decoratorsrc   s                                r1   collect_model_fieldsr   N   s3   > )**I)++JME13 6 6"4)>EEE< 	6 ''5553C[QQQJ ,""#4b99K#%F55J+5+;+;+=+= S& S&''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$$$ h0ABB"8,, 	& 	8v+=+=nhnnn   !&ErJJNNxXX 	 	D   EPE]^bEcEc)k);D)A)A)Aik      tX&& >))/// ;..-8 - -33C - -)- - -   ...;&&(:N*N*N (77JZJ`7aa
  ?+0J( 7?J3 ""6x"@AA

 0(CCC.*55 S:L^Mc:d:d S *8)?)G)Gc)R)R& /8vJ~Wa<b<bv$$&&&hv   $<<X~_o_u<vvJ /BJ+ ',
$2:
//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 7]]__ 	7 	7E 7((666. 4&sF333:s    R11
R>=R>r   rM   rw   c                8   t                      }t          | dd           }|rv|D ]u}t          j        t	          |                    rPt          j        |          D ];}t          ||          r)|j        "t          j
        d| dt                       d S <td S d S )N__args__z `alias` specification on field "z5" must be set on outermost annotation to take effect.)r   ro   r   is_annotatedr   r   get_argsru   aliasr}   r~   r   )r   rM   r#   argsanno_arganno_type_args         r1   r   r     s    (**I8Z..D 	 	 	H*:h+?+?@@ %2%;H%E%E  M!-;; @S@_ ~x~~~'   	 		 	r0   r   Mapping[TypeVar, Any]c               &   t                      }i }|                    |           5  | j                                        D ]\  }}|j        r|||<   |j        }t          j        |j        g|j	        R  }t          j        ||          }|j        x}	t          u r"|                    |t          j                  }
n"|                    ||	t          j                  }
|
j        |
j        n||
_        |
||<   	 ddd           n# 1 swxY w Y   |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.

    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.
    rf   N)r   pushrX   rJ   r   rK   r   	eval_typer   types_namespacer   replace_typesr   r   r   r   r   r   )rA   rS   rP   r   rebuilt_fieldsf_namerN   existing_descannassign	new_fields              r1   rebuild_model_fieldsr   -  s   " *++J+-N			#		 3 3"%"9"?"?"A"A 	3 	3FJ# 3)3v&& * 6#-3 0    -c<@@(==FBSSS * : :3HXH^ : _ _II * C CCYiYo C p pIAJAVAb	(=(=hu	%)2v&&#	33 3 3 3 3 3 3 3 3 3 3 3 3 3 3( s   CDD
D
)rS   rP   rR   type[StandardDataclass]dict[Any, Any] | NoneConfigWrapper | Nonec          
        t                      }i }|pt                      }| j        }t          | j                  D ]}t          j        |          s|                    |          5  |                                D ]\  }}	||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        |          rd|	j        j        r$|	j        j        du rt-          d| dd          |                    ||	j        t0          j                  }|	j        |_        n)|                    ||	t0          j                  }|	|_        |sd|_        ||_        |||<   |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.
        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.
    rY   FzDataclass field zD has init=False and init_var=True, but these are mutually exclusive.zclashing-init-and-init-var)coderf   N__is_pydantic_dataclass__rI   )%r   r   __dataclass_fields__rn   __mro__r   r   r   rJ   r<   rr   r   r   try_eval_typetyper   initr   MISSINGdefault_factoryru   init_varr   r   r   	DATACLASSr   r   r   r   ro   setattrr   r   r   rO   ry   )rA   rS   rP   rR   r   rC   r   r   rM   dataclass_fieldglobalnslocalnsr   r   rN   rc   s                   r1   collect_dataclass_fieldsr   X  sH   & *++J#%F-K/
 %% 8? 8?'-- 	d## 4	? 4	?-=-C-C-E-E 3? 3?)/4=#4#45F#K#KKK $/$?!'&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 %->>>:C:66
D D> C:+=>>>g3?4	? 4	? 4	? 4	? 4	? 4	? 4	? 4	? 4	? 4	? 4	? 4	? 4	? 4	? 4	?l  3]]__ 	3 	3E $$\2222!n&M!& $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||
_        |
||<   	 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.
    rf   N)r   r   rX   rJ   r   rK   r   r   r   r   r   r   r   r   r   r   )rA   rR   rS   rP   r   r   r   rN   r   r   r   s              r1   rebuild_dataclass_fieldsr     s]   $ *++J+-N			#		 3 3"%"9"?"?"A"A 	3 	3FJ# 3)3v&& * 6#-3 0    -c<@@&??3,6 @  	 BKAVAb	(=(=hu	%)2v&&%	33 3 3 3 3 3 3 3 3 3 3 3 3 3 3* s   B&CC Cra   c                .    |                      d           S )N_rx   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          |           }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	   
ValueErrorr   list
parametersr   lenr   r   r   empty)r   sigr   s      r1   takes_validated_data_argumentr     s    ((	"    uu
 cn++--..Jz??aq$5jm$D$DqTUI^bkbqIqqs    '')r2   r   r3   r!   )r3   r7   )F)rA   rB   rC   rD   rE   rF   r3   rG   )
rA   rQ   rR   r   rS   rT   rP   rU   r3   rV   )r   rB   rM   rw   r3   rG   )rA   rQ   rS   r   rP   r   r3   rD   )
rA   r   rS   rT   rP   r   rR   r   r3   rD   )
rA   r   rR   r   rS   r   rP   r   r3   rD   )ra   rw   r3   rF   )r   r   r3   r   )Jr.   
__future__r   _annotationsr   r}   collections.abcr   r   	functoolsr   inspectr   r   r	   rer
   typingr   r   r   r   pydantic_corer   typing_extensionsr   r   typing_inspectionr   typing_inspection.introspectionr   pydanticr   pydantic.errorsr    r   r   _configr   _docs_extractionr   _import_utilsr   r   _namespace_utilsr   _reprr   _utilsr   r@   r!   rC   r#   mainr$   _dataclassesr%   r&   _decoratorsr'   r)   r6   r5   rO   r   r   r   r   r   r   r   r   r*   r0   r1   <module>r      s{   s s 2 2 2 2 2 2      # # # # # #             < < < < < < < < < <       8 8 8 8 8 8 8 8 8 8 8 8 + + + + + + 0 0 0 0 0 0 0 0 , , , , , , < < < < < < / / / / / / - - - - - - & & & & & & & & " " " " " " 9 9 9 9 9 9 M M M M M M M M ( ( ( ( ( ( ! ! ! ! ! ! % % % % % % ,,,,,,,""""""      BBBBBBBB++++++    ~   	- 	- 	- 	- 
$ 
$ 
$ 
$; ; ; ; ; 26L L L L L L^    ( ( ( (\ &**.+/f f f f f fR* * * *Z$ $ $ $> > > >r r r r r rr0   