U
    ={f/                  (   @  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seZerddl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&Z!ddddd Z"e#ej$% Z&d!d"d#d$d%d&d'd(d)d*h
Z'd+d,d-d.d/d0d1d2d3d4d5
Z(dd6d7d8d9Z)dS ):    )annotationsN)contextmanager)TYPE_CHECKINGAnyCallablecast)core_schema)LiteralSelf   )AliasGenerator)
ConfigDictExtraValuesJsonDictJsonEncoderJsonSchemaExtraCallable)PydanticUserError)PydanticDeprecatedSince20)GenerateSchemazGSupport 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d/< d0ed1< d2ed3< ded4< d5ed6< ded7< d8ed9< ded:< ded;< d<ed=< d>d?d@ddAdBdCZedDdEdEdFdGdHdIZe	sdJdKdLdMdNZ
dKdOdPdQdRZdSdT ZdUS )V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tuple[type, ...]ignored_typesallow_inf_nanz)JsonDict | JsonSchemaExtraCallable | Nonejson_schema_extraz&dict[type[object], JsonEncoder] | Nonejson_encodersstrictz2Literal[('always', 'never', 'subclass-instances')]revalidate_instanceszLiteral[('iso8601', 'float')]ser_json_timedeltazLiteral[('utf8', 'base64')]ser_json_byteszLiteral[('null', 'constants')]ser_json_inf_nanvalidate_defaultvalidate_returnztuple[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_stringsTcheck.ConfigDict | dict[str, Any] | type[Any] | None)configr@   c                C  s    |rt || _ntt|| _d S N)prepare_configr   r   r   )selfrB   r@    rF   Y/var/www/html/Darija-Ai-API/env/lib/python3.8/site-packages/pydantic/_internal/_config.py__init__X   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rh|shtddd|r||r|tdd	d|pt|}
||
 t| D ]}|t	k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   rD   listkeysconfig_keyspop)clsrI   rJ   rK   Z
config_newbaserB   Zconfig_class_from_namespaceZconfig_dict_from_namespaceZraw_annotationsZconfig_from_namespacekrF   rF   rG   	for_model^   s*    


zConfigWrapper.for_modelstrr   )namerL   c                 C  sZ   z| j | W S  tk
rT   zt| W  Y S  tk
rN   td|d Y nX Y nX d S )NzConfig has no attribute )r   KeyErrorconfig_defaultsAttributeError)rE   r\   rF   rF   rG   __getattr__   s    zConfigWrapper.__getattr__zcore_schema.CoreConfig)objrL   c                 C  s
  ddddd}t jf || jdp,|o,|j| jd| jd| jd| jd	| jd
| jd| jd| jd| jd| jd| jd| jd| jd| jd| jd| jd| jd| jd| jd| jd| j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   )rK   rL   c                  [  s   dd |   D S )Nc                 S  s   i | ]\}}|d k	r||qS rC   rF   .0rY   vrF   rF   rG   
<dictcomp>   s       zDConfigWrapper.core_config.<locals>.dict_not_none.<locals>.<dictcomp>)items)rK   rF   rF   rG   dict_not_none   s    z0ConfigWrapper.core_config.<locals>.dict_not_noner   r   r)   r!   r   r   r   r,   r.   r/   r0   r%   r&   r-   r1   r   r   r4   r:   r;   r<   r>   )r   Zextra_fields_behaviorr)   r!   r   r   r   r,   r.   r/   r0   r%   r&   r-   r1   r   r   r4   r:   r;   r<   r>   )r   Z
CoreConfigr   rR   __name__)rE   ra   rg   core_configrF   rF   rG   ri      s8    




















zConfigWrapper.core_configc                 C  s&   d dd | j D }d| dS )Nz, c                 s  s    | ]\}}| d |V  qdS )=NrF   rb   rF   rF   rG   	<genexpr>   s     z)ConfigWrapper.__repr__.<locals>.<genexpr>zConfigWrapper())joinr   rf   )rE   crF   rF   rG   __repr__   s    zConfigWrapper.__repr__N)rh   
__module____qualname____doc__	__slots__rM   rH   classmethodrZ   r   r`   ri   ro   rF   rF   rF   rG   r   "   s`   
.	-r   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 rC   _config_wrapper_stackrE   rv   rF   rF   rG   rH      s    zConfigWrapperStack.__init__)rL   c                 C  s
   | j d S )Nrw   )rE   rF   rF   rG   tail   s    zConfigWrapperStack.tailz!ConfigWrapper | ConfigDict | Nonec                 c  sP   |d krd V  d S t |ts(t|dd}| j| z
d V  W 5 | j  X d S )NFr?   )
isinstancer   rx   appendrV   ry   rF   rF   rG   push   s    

zConfigWrapperStack.pushN)	rh   rp   rq   rr   rH   propertyr{   r   r~   rF   rF   rF   rG   ru      s   ru   FTrF   neverZiso8601utf8null)Zmodel_z
rust-regex)&r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r,   r-   r.   r/   r0   r1   r2   r3   r4   r+   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   rA   r   )rB   rL   c                   sP    dk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 )__)
startswithrO   rc   rY   rB   rF   rG   re     s     
  z"prepare_config.<locals>.<dictcomp>)
r   r|   dictwarningswarnDEPRECATION_MESSAGEDeprecationWarningdirr   check_deprecated)rB   r   rF   r   rG   rD     s    	

rD   Zallow_mutationZerror_msg_templatesfieldsZgetter_dictZsmart_unionZunderscore_attrs_are_privateZ
json_loadsZ
json_dumpsZcopy_on_model_validationZpost_init_callr!   r   r   r   r(   r   r   r%   r*   r1   )
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   rL   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 rF   )V2_RENAMED_KEYSr   rF   rF   rG   re   J  s      z$check_deprecated.<locals>.<dictcomp>c                 S  s    g | ]\}}d |d|qS )* z has been renamed to rF   rb   rF   rF   rG   
<listcomp>K  s     z$check_deprecated.<locals>.<listcomp>c                 S  s   g | ]}d |dqS )r   z has been removedrF   r   rF   rF   rG   r   L  s     
z%Valid config keys have changed in V2:N)	V2_REMOVED_KEYSrT   r   sortedrf   rm   r   r   UserWarning)r   Zdeprecated_removed_keysZdeprecated_renamed_keysZ	renamingsZrenamed_bulletsZremoved_bulletsmessagerF   rF   rG   r   A  s    r   )*
__future__r   Z_annotationsr   
contextlibr   typingr   r   r   r   Zpydantic_corer   Ztyping_extensionsr	   r
   aliasesr   rB   r   r   r   r   r   errorsr   r   r   Z#_internal._schema_generation_sharedr   r   r   ru   r^   rD   setrM   rT   rU   r   r   r   rF   rF   rF   rG   <module>   s    )+