a
    “˜ëj÷9  ã                2   @  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	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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d�0Z&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 d0d1œd2d3„Z.dS )4é    )Ú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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< dedK< dLdMœdNddOœdPdQ„ZedRdSdSdSdTdUœdVdW„ƒZe	�sàdXdYdZœd[d\„Z
dd]d^œd_d`„Zdadb„ ZdcS )dÚ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['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_pathÚpolymorphic_serializationT©Úcheckú.ConfigDict | dict[str, Any] | type[Any] | None)ÚconfigrN   c                C  s    |rt |ƒ| _ntt|ƒ| _d S ©N)Úprepare_configr   r	   r   )ÚselfrP   rN   © rT   úY/mnt/bigstor/www/usecases/.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Úraw_annotationsÚkwargsÚreturnc                 C  sº   t ƒ }|D ]"}t|ddƒ}|r
| | ¡ ¡ q
| d¡}| d¡}	| d¡r`|	du r`tddd�‚|rt|	rttddd�‚|	p~t|ƒ}
| |
¡ t| ¡ ƒD ]}|t	v r–| 
|¡||< q–| |ƒ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`.
        Zmodel_configNZ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   rR   ÚlistÚkeysÚconfig_keysÚpop)ÚclsrW   rX   rY   rZ   Z
config_newÚbaserP   Zconfig_class_from_namespaceZconfig_dict_from_namespaceZconfig_from_namespaceÚkrT   rT   rU   Ú	for_modelc   s(    

þ
zConfigWrapper.for_modelÚstrr   )Únamer[   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)rS   rk   rT   rT   rU   Ú__getattr__š   s    zConfigWrapper.__getattr__zcore_schema.CoreConfig)r   r[   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
¡sœtddd�‚tjf i dd„ d| d¡p¼|p¼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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%   rI   TrH   FzNAt least one of `validate_by_alias` or `validate_by_name` must be set to True.z validate-by-alias-and-name-falser\   c                 S  s   i | ]\}}|d ur||“qS rQ   rT   ©Ú.0rh   ÚvrT   rT   rU   Ú
<dictcomp>Ê   s   àz-ConfigWrapper.core_config.<locals>.<dictcomp>r   Zextra_fields_behaviorr#   r/   r   r   r   r2   r4   r5   r6   r7   r8   r9   r)   r*   r3   r:   r"   r!   r=   rC   rD   rE   rG   rJ   rK   rL   )r   ra   ÚwarningsÚwarnr   r   r
   Z
CoreConfig)rS   r   rP   r%   rT   rT   rU   Úcore_config£   sh    ýþãþÿzConfigWrapper.core_configc                 C  s&   d  dd„ | j ¡ D ƒ¡}d|› d�S )Nz, c                 s  s    | ]\}}|› d |›�V  qdS )ú=NrT   rr   rT   rT   rU   Ú	<genexpr>ð   ó    z)ConfigWrapper.__repr__.<locals>.<genexpr>zConfigWrapper(ú))Újoinr   Úitems)rS   ÚcrT   rT   rU   Ú__repr__ï   s    zConfigWrapper.__repr__N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__Ú__annotations__rV   Úclassmethodri   r   ro   rx   r€   rT   rT   rT   rU   r      st   
4	Lr   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 rQ   ©Ú_config_wrapper_stack©rS   r‰   rT   rT   rU   rV   ÷   s    zConfigWrapperStack.__init__)r[   c                 C  s
   | j d S )NéÿÿÿÿrŠ   )rS   rT   rT   rU   Ú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 )NFrM   )Ú
isinstancer   r‹   Úappendre   rŒ   rT   rT   rU   Úpushþ   s    
zConfigWrapperStack.pushN)	r�   r‚   rƒ   r„   rV   ÚpropertyrŽ   r   r‘   rT   rT   rT   rU   rˆ   ô   s   rˆ   FTrT   ÚneverZiso8601ZinferÚutf8Únull)Zmodel_validateZ
model_dumpz
rust-regex)0r   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;   r<   r=   r1   r>   r@   r?   rA   rB   rC   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rO   r   )rP   r[   c                   sT   ˆ du rt ƒ S tˆ tƒs>tjttdd� ‡ fdd„tˆ ƒD ƒ‰ tt ˆ ƒ}t	|ƒ |S )zÕCreate 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.
    Né   rp   c                   s"   i | ]}|  d ¡s|tˆ |ƒ“qS )Ú__)Ú
startswithr^   ©rs   rh   ©rP   rT   rU   ru   Q  r{   z"prepare_config.<locals>.<dictcomp>)
r   r�   Údictrv   rw   ÚDEPRECATION_MESSAGEr   Údirr	   Úcheck_deprecated)rP   r   rT   rš   rU   rR   C  s    	

rR   >
   ÚfieldsZunderscore_attrs_are_privateZcopy_on_model_validationZsmart_unionZerror_msg_templatesZallow_mutationZgetter_dictZ
json_loadsZ
json_dumpsZpost_init_callrI   r   r   r   r.   r"   r!   r)   r0   r:   )
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   r[   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 rT   )ÚV2_RENAMED_KEYSr™   rT   rT   rU   ru   ~  r{   z$check_deprecated.<locals>.<dictcomp>c                 S  s    g | ]\}}d |›d|›�‘qS )ú* z has been renamed to rT   rr   rT   rT   rU   Ú
<listcomp>  r{   z$check_deprecated.<locals>.<listcomp>c                 S  s   g | ]}d |›d�‘qS )r¢   z has been removedrT   r™   rT   rT   rU   r£   €  r{   Ú
z%Valid config keys have changed in V2:N)	ÚV2_REMOVED_KEYSrc   r¡   Úsortedr~   r}   rv   rw   ÚUserWarning)r   Zdeprecated_removed_keysZdeprecated_renamed_keysZ	renamingsZrenamed_bulletsZremoved_bulletsÚmessagerT   rT   rU   rž   u  s    rž   )/Ú
__future__r   Z_annotationsrv   Ú
contextlibr   Úrer   Útypingr   r   r   r   r	   Zpydantic_corer
   Ztyping_extensionsr   Úaliasesr   rP   r   r   r   r   r   Úerrorsr   r   r   Z#_internal._schema_generation_sharedr   rŸ   r   r   rœ   r   rˆ   rm   rR   Úsetr†   rc   rd   r¥   r¡   rž   rT   rT   rT   rU   Ú<module>   s¤    XÏ5ö