
    hR9                       d dl mZ d dlZd dl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mZmZmZmZ ddlmZ ddlmZmZ e	rddlmZ ddl m!Z!m"Z" dZ# G d d      Z$ G d d      Z% ed(i dddddddddd ddddddddddddd dd!dd"d#d$dd%dd&dd'd(d)d#d*dd+dd,d-d.d/d0d/d1d2d3d4d5d4d6d7d8dd9dd:d;d<dd=dd>dd?dd@ddAddBddCddDdEdFddGddHd#dId#dJddKddLdZ&dQdMZ' e(ejR                  jU                               Z+h dNZ,dJdddd'ddd!d*d8dO
Z-dRdPZ.y)S    )annotationsN)contextmanager)Pattern)TYPE_CHECKINGAnyCallableLiteralcast)core_schema)Self   )AliasGenerator)
ConfigDictExtraValuesJsonDictJsonEncoderJsonSchemaExtraCallable)PydanticUserError)PydanticDeprecatedSince20PydanticDeprecatedSince210)GenerateSchema)ComputedFieldInfo	FieldInfozGSupport for class-based `config` is deprecated, use ConfigDict instead.c                  D   e Zd ZU dZ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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.ed0<   d1ed2<   ded3<   ded4<   d5ed6<   ded7<   ded8<   d9ed:<   d;ed<<   ded=<   d>ed?<   ded@<   dAedB<   dedC<   dedD<   dEedF<   dedG<   dedH<   dedI<   dedJ<   dKdLdSdMZe	 	 	 	 	 	 	 	 	 	 dTdN       Ze	sdUdOZ
dVdPZdQ ZyR)WConfigWrapperzIInternal wrapper for Config which exposes ConfigDict items as attributes.)config_dictr   r   
str | Nonetitleboolstr_to_lowerstr_to_upperstr_strip_whitespaceintstr_min_lengthz
int | Nonestr_max_lengthzExtraValues | Noneextrafrozenpopulate_by_nameuse_enum_valuesvalidate_assignmentarbitrary_types_allowedfrom_attributesloc_by_aliasz,Callable[[str], str] | AliasGenerator | Nonealias_generatorzCallable[[type], str] | Nonemodel_title_generatorz:Callable[[str, FieldInfo | ComputedFieldInfo], str] | Nonefield_title_generatorztuple[type, ...]ignored_typesallow_inf_nanz)JsonDict | JsonSchemaExtraCallable | Nonejson_schema_extraz&dict[type[object], JsonEncoder] | Nonejson_encodersstrictz0Literal['always', 'never', 'subclass-instances']revalidate_instanceszLiteral['iso8601', 'float']ser_json_timedeltaz-Literal['iso8601', 'seconds', 'milliseconds']ser_json_temporalz+Literal['seconds', 'milliseconds', 'infer']val_temporal_unitz Literal['utf8', 'base64', 'hex']ser_json_bytesval_json_bytesz'Literal['null', 'constants', 'strings']ser_json_inf_nanvalidate_defaultvalidate_returnztuple[str | Pattern[str], ...]protected_namespaceshide_input_in_errorsdefer_buildzdict[str, object] | Noneplugin_settingsztype[GenerateSchema] | Noneschema_generator+json_schema_serialization_defaults_requiredz,Literal['validation', 'serialization', None]json_schema_mode_overridecoerce_numbers_to_strz"Literal['rust-regex', 'python-re']regex_enginevalidation_error_causeuse_attribute_docstringsz%bool | Literal['all', 'keys', 'none']cache_stringsvalidate_by_aliasvalidate_by_nameserialize_by_aliasurl_preserve_empty_pathTcheckc               T    |rt        |      | _        y t        t        |      | _        y N)prepare_configr   r
   r   )selfconfigrP   s      ?D:\jyotish\venv\Lib\site-packages\pydantic/_internal/_config.py__init__zConfigWrapper.__init__\   s!    -f5D#J7D    c                   t               }|D ]1  }t        |dd      }|s|j                  |j                                3 |j	                  d      }|j	                  d      }	|j	                  d      r|	t        dd      |r|	rt        dd      |	xs t        |      }
|j                  |
       t        |j                               D ]  }|t        v s|j                  |      ||<   !  | |      S )	aZ  Build a new `ConfigWrapper` instance for a `BaseModel`.

        The config wrapper built based on (in descending order of priority):
        - options from `kwargs`
        - options from the `namespace`
        - options from the base classes (`bases`)

        Args:
            bases: A tuple of base classes.
            namespace: The namespace of the class being created.
            raw_annotations: The (non-evaluated) annotations of the model.
            kwargs: The kwargs passed to the class being created.

        Returns:
            A `ConfigWrapper` instance for `BaseModel`.
        model_configNConfigz``model_config` cannot be used as a model field name. Use `model_config` for model configuration.zmodel-config-invalid-field-namecodez3"Config" and "model_config" cannot be used togetherzconfig-both)r   getattrupdatecopygetr   rS   listkeysconfig_keyspop)clsbases	namespaceraw_annotationskwargs
config_newbaserU   config_class_from_namespaceconfig_dict_from_namespaceconfig_from_namespaceks               rV   	for_modelzConfigWrapper.for_modelb   s    0  \
DT>48F!!&++-0 
 '0mmH&=#%.]]>%B"~.3M3U#r6 
 '+E#$Y`mnn : inMh>i/0fkkm$AK &

1
1 % :rX   c                    	 | j                   |   S # t        $ r) 	 t        |   cY S # t        $ r t        d|      d w xY ww xY w)NzConfig has no attribute )r   KeyErrorconfig_defaultsAttributeError)rT   names     rV   __getattr__zConfigWrapper.__getattr__   sb    X''-- XX*400 X(+CD8)LMSWWXXs    	A&A?Ac           #        | j                   }|j                  d      t        j                  dt        d       |j                  d      x}|j                  d      
d|d	<   ||d<   |j                  d	      d
u r|j                  d      d|d<   |j                  d	d      s|j                  dd
      st        dd      t        j                  d)i d|j                  d      xs |xs dfd|j                  d      fd|j                  d      fd|j                  d      fd|j                  d      fd|j                  d      fd|j                  d      fd|j                  d      fd|j                  d      fd|j                  d      fd|j                  d      fd|j                  d      fd|j                  d      fd|j                  d      fd|j                  d      fd|j                  d      fd|j                  d      fd |j                  d       fd!|j                  d!      fd"|j                  d"      fd#|j                  d#      fd$|j                  d$      fd%|j                  d%      fd&|j                  d&      fd	|j                  d	      fd|j                  d      fd'|j                  d'      fd(|j                  d(      ffD ci c]
  \  }}||| c}}S c c}}w )*a  Create a pydantic-core config.

        We don't use getattr here since we don't want to populate with defaults.

        Args:
            title: The title to use if not set in config.

        Returns:
            A `CoreConfig` object created from config.
        rC   NzfThe `schema_generator` setting has been deprecated since v2.10. This setting no longer has any effect.r   
stacklevelr(   rL   TrK   FzNAt least one of `validate_by_alias` or `validate_by_name` must be set to True.z validate-by-alias-and-name-falser\   r   extra_fields_behaviorr&   r2   r"   r    r!   r5   r7   r8   r9   r:   r;   r<   r,   r-   r6   r=   r%   r$   r@   rF   rG   rH   rJ   rM   rN    )r   ra   warningswarnr   r   r   
CoreConfig)rT   r   rU   r(   rp   vs         rV   core_configzConfigWrapper.core_config   s    !!::()5MMx* !'

+= >>K zz,-5.2*+-=)* ::)*e3

CU8V8^)-F%&

.5

K]_d@e#`7 
 %% #
 fjj1BUBdC,fjj.AB$fjj&AB+VZZ8N-OP#VZZ%?@#VZZ%?@vzz(34)6::6J+KL(&**5H*IJ(&**5H*IJ%vzz2B'CD%vzz2B'CD'4F)GH&

3D(EF#VZZ%?@+VZZ8N-OP'4F)GH%vzz2B'CD%vzz2B'CD+VZZ8N-OP,fjj9P.QR#VZZ%?@-vzz:R/ST$fjj&AB(&**5H*IJ'4F)GH)6::6J+KL.

;T0UV9!DAq< =? 1!#
 #	
!s   K-c                n    dj                  d | j                  j                         D              }d| dS )Nz, c              3  0   K   | ]  \  }}| d |  yw)=Nr|   ).0rp   r   s      rV   	<genexpr>z)ConfigWrapper.__repr__.<locals>.<genexpr>   s!     H/Gtq!1QEl/Gs   zConfigWrapper())joinr   items)rT   cs     rV   __repr__zConfigWrapper.__repr__   s4    IIHt/?/?/E/E/GHHs!$$rX   N)rU   .ConfigDict | dict[str, Any] | type[Any] | NonerP   r   )
rg   ztuple[type[Any], ...]rh   dict[str, Any]ri   r   rj   r   returnr   )rv   strr   r   )r   r   r   zcore_schema.CoreConfig)__name__
__module____qualname____doc__	__slots____annotations__rW   classmethodrq   r   rw   r   r   r|   rX   rV   r   r      s   S I L!! AA77UU##@@99 LJJ33DDBB4444==88--11155KK44  ""88!!`d 8 1$1 "1 (	1
 1 
1 1h 	XI
V%rX   r   c                  <    e Zd ZdZddZedd       Zedd       Zy)	ConfigWrapperStackz%A stack of `ConfigWrapper` instances.c                    |g| _         y rR   _config_wrapper_stackrT   config_wrappers     rV   rW   zConfigWrapperStack.__init__   s    ;I:J"rX   c                     | j                   d   S )Nr   )rT   s    rV   tailzConfigWrapperStack.tail   s    ))"--rX   c              #    K   |d  y t        |t              st        |d      }| j                  j                  |       	 d  | j                  j	                          y # | j                  j	                          w xY ww)NFrO   )
isinstancer   r   appendre   r   s     rV   pushzConfigWrapperStack.push   sh     !.-8*>GN"")).9	-&&**,D&&**,s   A BA" B"A>>BN)r   r   )r   r   )r   z!ConfigWrapper | ConfigDict | None)	r   r   r   r   rW   propertyr   r   r   r|   rX   rV   r   r      s3    /K . . - -rX   r   r   r    Fr!   r"   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   Tr.   r/   r0   r1   r|   r2   r3   r5   r6   neverr7   iso8601r8   r9   inferr:   utf8r;   r<   nullr=   r>   r?   )model_validate
model_dumpr@   r4   rA   rC   rB   rD   rE   rF   rG   z
rust-regexrH   rI   rJ   rK   rL   rM   rN   c                (   | 
t               S t        | t              sUt        j                  t
        t        d       t        |       D ci c]!  }|j                  d      r|t        | |      # } }t        t         |       }t        |       |S c c}w )zCreate a `ConfigDict` instance from an existing dict, a class (e.g. old class-based config) or None.

    Args:
        config: The input config.

    Returns:
        A ConfigDict object created from config.
       ry   __)r   r   dictr}   r~   DEPRECATION_MESSAGEr   dir
startswithr^   r
   check_deprecated)rU   rp   r   s      rV   rS   rS   @  s~     ~|fd#)+DQRS14VWAALLQUDV!WVQ''Wz6*K[!	 Xs   
B!B>
   fields
json_dumps
json_loadsgetter_dictsmart_unionallow_mutationpost_init_callerror_msg_templatescopy_on_model_validationunderscore_attrs_are_private)
allow_population_by_field_nameanystr_loweranystr_strip_whitespaceanystr_upperkeep_untouchedmax_anystr_lengthmin_anystr_lengthorm_modeschema_extravalidate_allc                   t         | j                         z  }t        j                         | j                         z  }|s|rt        |      D ci c]  }|t        |    }}|j	                         D cg c]  \  }}d|d| }}}t        |      D cg c]  }d|d
 }}dj                  dg|z   |z         }t        j                  |t               yyc c}w c c}}w c c}w )zjCheck for deprecated config keys and warn the user.

    Args:
        config_dict: The input config.
    z* z has been renamed to z has been removed
z%Valid config keys have changed in V2:N)	V2_REMOVED_KEYSrc   V2_RENAMED_KEYSsortedr   r   r}   r~   UserWarning)	r   deprecated_removed_keysdeprecated_renamed_keysrp   	renamingsr   renamed_bulletsremoved_bulletsmessages	            rV   r   r   r  s     .0@0@0BB-224{7G7G7II"94:;R4ST4SqQ**4S	TLUOOL]^L]DAqRu$9!?L]^@FG^@_`@_1Ru$56@_`))DEWZiijg{+ #:T^`s   C4CC$)rU   r   r   r   )r   r   r   None)/
__future__r   _annotationsr}   
contextlibr   rer   typingr   r   r   r	   r
   pydantic_corer   typing_extensionsr   aliasesr   rU   r   r   r   r   r   errorsr   r   r   #_internal._schema_generation_sharedr   r   r   r   r   r   r   rt   rS   setr   rc   rd   r   r   r   r|   rX   rV   <module>r      s   2  %   & " $ \ \ & LD5_ R% R%j- -4  1
11 1 	1
 1 1 1 1 1 1 1 "1 1 1  !1" #1$ %1& '1( )1* +1, -1. !/10 !112  314 516 718 91: ;1< =1> ?1@ :A1B C1D E1F G1H I1J K1L 16M1N #O1P  Q1R S1T !U1V #W1X Y1Z [1\ ]1^ _1` "a1h* *,,1134 '9"5"%))!'&,rX   