a
    h7                  .   @  s  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	seZe	rd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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,Z'ddd d!d"Z(e)ej*+ Z,h d#Z-d$d%d&d'd(d)d*d+d,d-d.
Z.dd/d0d1d2Z/dS )3    )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                   @  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< ded9< d:ed;< ded<< d=ed>< ded?< ded@< dAedB< dedC< dedD< dedE< dFdGdHddIdJdKZedLdMdMdNdOdPdQZe	sdRdSdTdUdVZ
ddWdXdYdZZd[d\ Zd]S )^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 | 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_aliasTcheck.ConfigDict | dict[str, Any] | type[Any] | None)configrJ   c                C  s    |rt || _ntt|| _d S N)prepare_configr   r	   r   )selfrL   rJ    rP   V/var/www/html/assistant/venv/lib/python3.9/site-packages/pydantic/_internal/_config.py__init__^   s    zConfigWrapper.__init__ztuple[type[Any], ...]zdict[str, Any]r   )bases	namespacekwargsreturnc                 C  s   t  }|D ]"}t|dd}|r
||  q
|d}|d}|di }	|	drl|du rltddd|r|rtdd	d|pt|}
||
 t| D ]}|t	v r|
|||< q| |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`.
        Zmodel_configNZ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   rN   listkeysconfig_keyspop)clsrS   rT   rU   Z
config_newbaserL   Zconfig_class_from_namespaceZconfig_dict_from_namespaceZraw_annotationsZconfig_from_namespacekrP   rP   rQ   	for_modeld   s*    


zConfigWrapper.for_modelstrr   )namerV   c                 C  sV   z| j | W S  tyP   zt| W  Y S  tyJ   td|d Y n0 Y n0 d S )NzConfig has no attribute )r   KeyErrorconfig_defaultsAttributeError)rO   rg   rP   rP   rQ   __getattr__   s    zConfigWrapper.__getattr__zcore_schema.CoreConfig)r   rV   c                  C  s  | j }|ddur$tjdtdd |d }durT|ddu rTd|d	< ||d< |d	d
u rx|ddu rxd|d< |d	ds|dd
stdddtjf i dd d|dp|pdfd|dfd|dfd|dfd|dfd|dfd|dfd|dfd|dfd|dfd|dfd|dfd|dfd|dfd|dfd |d fd!|d!fd"|d"fd#|d#fd$|d$fd%|d%fd&|d&fd	|d	fd|dfd'|d'ffD S )(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.
        r>   NzfThe `schema_generator` setting has been deprecated since v2.10. This setting no longer has any effect.r   )
stacklevelr%   rG   TrF   FzNAt least one of `validate_by_alias` or `validate_by_name` must be set to True.z validate-by-alias-and-name-falserX   c                 S  s   i | ]\}}|d ur||qS rM   rP   .0rd   vrP   rP   rQ   
<dictcomp>   s   z-ConfigWrapper.core_config.<locals>.<dictcomp>r   Zextra_fields_behaviorr#   r/   r   r   r   r2   r4   r5   r6   r7   r)   r*   r3   r8   r"   r!   r;   rA   rB   rC   rE   rH   )r   r]   warningswarnr   r   r
   Z
CoreConfig)rO   r   rL   r%   rP   rP   rQ   core_config   s`    zConfigWrapper.core_configc                 C  s&   d dd | j D }d| dS )Nz, c                 s  s    | ]\}}| d |V  qdS )=NrP   rm   rP   rP   rQ   	<genexpr>       z)ConfigWrapper.__repr__.<locals>.<genexpr>zConfigWrapper())joinr   items)rO   crP   rP   rQ   __repr__   s    zConfigWrapper.__repr__N)__name__
__module____qualname____doc__	__slots__rW   rR   classmethodre   r   rk   rs   r{   rP   rP   rP   rQ   r   "   sl   
.	Hr   c                   @  sB   e Zd ZdZddddZeddddZed	dd
dZdS )ConfigWrapperStackz%A stack of `ConfigWrapper` instances.r   )config_wrapperc                 C  s   |g| _ d S rM   _config_wrapper_stackrO   r   rP   rP   rQ   rR      s    zConfigWrapperStack.__init__)rV   c                 C  s
   | j d S )Nr   )rO   rP   rP   rQ   tail   s    zConfigWrapperStack.tailz!ConfigWrapper | ConfigDict | Nonec                 c  sZ   |d u rd V  d S t |ts(t|dd}| j| zd V  W | j  n| j  0 d S )NFrI   )
isinstancer   r   appendra   r   rP   rP   rQ   push   s    
zConfigWrapperStack.pushN)	r|   r}   r~   r   rR   propertyr   r   r   rP   rP   rP   rQ   r      s   r   FTrP   neverZiso8601utf8null)Zmodel_validateZ
model_dumpz
rust-regex),r   r   r   r   r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r1   r<   r>   r=   r?   r@   rA   rB   rC   rD   rE   rF   rG   rH   rK   r   )rL   rV   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 )__)
startswithrZ   rn   rd   rL   rP   rQ   rp   D  rv   z"prepare_config.<locals>.<dictcomp>)
r   r   dictrq   rr   DEPRECATION_MESSAGEDeprecationWarningdirr	   check_deprecated)rL   r   rP   r   rQ   rN   6  s    	

rN   >
   Zunderscore_attrs_are_privateZ
json_loadsZpost_init_callZcopy_on_model_validationZallow_mutationZ
json_dumpsZerror_msg_templatesZgetter_dictfieldsZsmart_unionrG   r   r   r   r.   r"   r!   r)   r0   r8   )
Zallow_population_by_field_nameZanystr_lowerZanystr_strip_whitespaceZanystr_upperZkeep_untouchedZmax_anystr_lengthZmin_anystr_lengthZorm_modeZschema_extraZvalidate_allNone)r   rV   c                 C  s~   t |  @ }t |  @ }|s$|rzdd t|D }dd | D }dd t|D }ddg| | }t|t dS )	zjCheck for deprecated config keys and warn the user.

    Args:
        config_dict: The input config.
    c                 S  s   i | ]}|t | qS rP   )V2_RENAMED_KEYSr   rP   rP   rQ   rp   q  rv   z$check_deprecated.<locals>.<dictcomp>c                 S  s    g | ]\}}d |d|qS )* z has been renamed to rP   rm   rP   rP   rQ   
<listcomp>r  rv   z$check_deprecated.<locals>.<listcomp>c                 S  s   g | ]}d |dqS )r   z has been removedrP   r   rP   rP   rQ   r   s  rv   
z%Valid config keys have changed in V2:N)	V2_REMOVED_KEYSr_   r   sortedry   rx   rq   rr   UserWarning)r   Zdeprecated_removed_keysZdeprecated_renamed_keysZ	renamingsZrenamed_bulletsZremoved_bulletsmessagerP   rP   rQ   r   h  s    r   )0
__future__r   Z_annotationsrq   
contextlibr   rer   typingr   r   r   r   r	   Zpydantic_corer
   Ztyping_extensionsr   aliasesr   rL   r   r   r   r   r   errorsr   r   r   r   Z#_internal._schema_generation_sharedr   r   r   r   r   r   r   ri   rN   setrW   r_   r`   r   r   r   rP   rP   rP   rQ   <module>   s    J1