o
    ?Hh0                     @  s*  d dl mZ d dl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mZmZmZmZ dd
lmZ ddlmZ esNeZer^ddlmZ ddlmZm Z  dZ!G dd dZ"G d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.d/d0d1d0d2d3d4dd5dd6d7d8dd9dd:dd;d<d=dd>dd?dd@ddAddBdCdDddEddFd"Z$dSdKdLZ%e&ej'( Z)h dMZ*ddddd&ddd d)d4dN
Z+dTdQdRZ,dS )U    )annotationsN)contextmanager)TYPE_CHECKINGAnyCallablecast)core_schema)LiteralSelf   )AliasGenerator)
ConfigDictExtraValuesJsonDictJsonEncoderJsonSchemaExtraCallable)PydanticUserError)PydanticDeprecatedSince20)GenerateSchema)ComputedFieldInfo	FieldInfozGSupport for class-based `config` is deprecated, use ConfigDict instead.c                   @  s  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d/< ded0< d1ed2< ded3< ded4< d5ed6< d7ed8< d9ed:< ded;< d<ed=< ded>< d?ed@< dedA< dedB< dCedD< dEdFdadJdKZedbdSdTZe	sdcdXdYZ
ddd\d]Zd^d_ Zd`S )eConfigWrapperzIInternal wrapper for Config which exposes ConfigDict items as attributes.)config_dictr   r   z
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['utf8', 'base64', 'hex']ser_json_bytesval_json_bytesz'Literal['null', 'constants', 'strings']ser_json_inf_nanvalidate_defaultvalidate_returnztuple[str, ...]protected_namespaceshide_input_in_errorsdefer_buildz,tuple[Literal['model', 'type_adapter'], ...]experimental_defer_build_modez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_stringsTcheckconfig.ConfigDict | dict[str, Any] | type[Any] | NonerF   c                C  s"   |r	t || _d S tt|| _d S N)prepare_configr   r   r   )selfrG   rF    rL   Z/home/air/sanwanet/gpt-api/venv/lib/python3.10/site-packages/pydantic/_internal/_config.py__init__]   s   zConfigWrapper.__init__basestuple[type[Any], ...]	namespacedict[str, Any]kwargsreturnr
   c                 C  s   t  }|D ]}t|dd}|r||  q|d}|d}|di }	|	dr4|s4tddd|r>|r>tdd	d|pCt|}
||
 t| D ]}|t	v r\|
|||< qO| |S )
a  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.
            kwargs: The kwargs passed to the class being created.

        Returns:
            A `ConfigWrapper` instance for `BaseModel`.
        model_configNConfig__annotations__z``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   rJ   listkeysconfig_keyspop)clsrO   rQ   rS   
config_newbaserG   config_class_from_namespaceconfig_dict_from_namespaceraw_annotationsconfig_from_namespacekrL   rL   rM   	for_modelc   s.   


zConfigWrapper.for_modelnamestrr   c                 C  sJ   z| j | W S  ty$   zt| W  Y S  ty#   td|d w w )NzConfig has no attribute )r   KeyErrorconfig_defaultsAttributeError)rK   rj   rL   rL   rM   __getattr__   s   zConfigWrapper.__getattr__objcore_schema.CoreConfigc              	   C  s4  | j }i d|dp|o|j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}tjdi dd | D S )a  Create a pydantic-core config, `obj` is just used to populate `title` if not set in config.

        Pass `obj=None` if you do not want to attempt to infer the `title`.

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

        Args:
            obj: An object used to populate `title` if not set in config.

        Returns:
            A `CoreConfig` object created from config.
        r   extra_fields_behaviorr!   r-   r#   r   r   r   r0   r2   r3   r4   r5   r'   r(   r1   r6   r    r   r9   r@   rA   rB   rD   )r   r9   r@   rA   rB   rD   c                 S  s   i | ]\}}|d ur||qS rI   rL   .0rh   vrL   rL   rM   
<dictcomp>   s    z-ConfigWrapper.core_config.<locals>.<dictcomp>NrL   )r   r\   __name__r   
CoreConfigitems)rK   rp   rG   core_config_valuesrL   rL   rM   core_config   sX   







	








zConfigWrapper.core_configc                 C  s&   d dd | j D }d| dS )Nz, c                 s  s"    | ]\}}| d |V  qdS )=NrL   rs   rL   rL   rM   	<genexpr>   s     z)ConfigWrapper.__repr__.<locals>.<genexpr>zConfigWrapper())joinr   ry   )rK   crL   rL   rM   __repr__   s   zConfigWrapper.__repr__N)rG   rH   rF   r   )rO   rP   rQ   rR   rS   rR   rT   r
   )rj   rk   rT   r   )rp   r   rT   rq   )rw   
__module____qualname____doc__	__slots__rW   rN   classmethodri   r   ro   r{   r   rL   rL   rL   rM   r   #   sj   
 .

	+r   c                   @  s6   e Zd ZdZdddZedddZedd
dZdS )ConfigWrapperStackz%A stack of `ConfigWrapper` instances.config_wrapperr   c                 C  s   |g| _ d S rI   _config_wrapper_stackrK   r   rL   rL   rM   rN      s   zConfigWrapperStack.__init__rT   c                 C  s
   | j d S )Nr   )rK   rL   rL   rM   tail   s   
zConfigWrapperStack.tail!ConfigWrapper | ConfigDict | Nonec                 c  sZ    |d u r
d V  d S t |tst|dd}| j| zd V  W | j  d S | j  w )NFrE   )
isinstancer   r   appendr`   r   rL   rL   rM   push   s   
zConfigWrapperStack.pushN)r   r   )rT   r   )r   r   )	rw   r   r   r   rN   propertyr   r   r   rL   rL   rL   rM   r      s    
r   r   r   Fr   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   Tr)   r*   r+   r,   rL   r-   r.   r0   r1   neverr2   iso8601r3   utf8r4   r5   nullr6   r7   r8   )model_r9   r/   r:   r;   )modelr<   r=   r>   r?   r@   rA   z
rust-regexrB   rC   rD   rG   rH   rT   r   c                   sP    du rt  S t tsttt  fddt D  tt  }t	| |S )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.
    Nc                   s"   i | ]}| d s|t |qS )__)
startswithrY   rt   rh   rG   rL   rM   rv   $  s   " z"prepare_config.<locals>.<dictcomp>)
r   r   dictwarningswarnDEPRECATION_MESSAGEDeprecationWarningdirr   check_deprecated)rG   r   rL   r   rM   rJ     s   	

rJ   >
   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_allr   Nonec                 C  s   t |  @ }t |  @ }|s|r?dd t|D }dd | D }dd t|D }ddg| | }t|t dS dS )	zjCheck for deprecated config keys and warn the user.

    Args:
        config_dict: The input config.
    c                 S  s   i | ]}|t | qS rL   )V2_RENAMED_KEYSr   rL   rL   rM   rv   Q  s    z$check_deprecated.<locals>.<dictcomp>c                 S  s    g | ]\}}d |d|qS )* z has been renamed to rL   rs   rL   rL   rM   
<listcomp>R  s     z$check_deprecated.<locals>.<listcomp>c                 S  s   g | ]}d |dqS )r   z has been removedrL   r   rL   rL   rM   r   S  s    
z%Valid config keys have changed in V2:N)	V2_REMOVED_KEYSr^   r   sortedry   r   r   r   UserWarning)r   deprecated_removed_keysdeprecated_renamed_keys	renamingsrenamed_bulletsremoved_bulletsmessagerL   rL   rM   r   H  s   r   )rG   rH   rT   r   )r   r   rT   r   )-
__future__r   _annotationsr   
contextlibr   typingr   r   r   r   pydantic_corer   typing_extensionsr	   r
   aliasesr   rG   r   r   r   r   r   errorsr   r   r   #_internal._schema_generation_sharedr   r   r   r   r   r   r   rm   rJ   setrW   r^   r_   r   r   r   rL   rL   rL   rM   <module>   s     +	
 !"#$%&'()*+
/