o
    ûT·jõ  ã                   @   sx  d dl Z d dlZd dlmZmZmZ d dlZd dlmZm	Z	m
Z
mZ d dlmZmZ d dlmZmZ d dlmZ ddlmZ erFdd	lmZ d
eeB dB defdd„Zdedee fdd„ZdZe
dddfdedededB dedB dedB ded defdd„Zdedededefdd„Z dd defd!d"„Z!d#e"eef d$e"eef ddfd%d&„Z#d'eeB d(eeB deeB fd)d*„Z$dS )+é    N)ÚTYPE_CHECKINGÚAnyÚLiteral)Ú
ModelFieldÚPydanticSchemaGenerationErrorÚ	UndefinedÚannotation_is_pydantic_v1)ÚDefaultPlaceholderÚDefaultType)ÚFastAPIDeprecationWarningÚPydanticV1NotSupportedError)Ú	FieldInfoé   )Úv2)ÚAPIRouteÚstatus_codeÚreturnc                 C   s2   | d u rdS | dv rdS t | ƒ}|dk p|dv  S )NT>   Ú1XXÚ2XXÚ3XXÚ4XXÚ5XXÚdefaultéÈ   >   é0  éÌ   éÍ   )Úint)r   Úcurrent_status_code© r   úP/home/dinkstrade/pdmp-scanner/venv/lib/python3.10/site-packages/fastapi/utils.pyÚis_body_allowed_for_status_code   s   r!   Úpathc                 C   s   t t d| ¡ƒS )Nz{(.*?)})ÚsetÚreÚfindall)r"   r   r   r    Úget_path_param_names+   s   r&   a’  Invalid args for response field! Hint: check that {type_} is a valid Pydantic field type. If you are using a return type annotation that is not a valid Pydantic field (e.g. Union[Response, dict, None]) you can disable generating the response model from the type annotation with the path operation decorator parameter response_model=None. Read more: https://fastapi.tiangolo.com/tutorial/response-model/Ú
validationÚnameÚtype_r   Ú
field_infoÚaliasÚmode)r'   Úserializationc                 C   sb   t |ƒrtd|›d�ƒ‚|pt|||d�}z	tj|| |d�W S  ty0   tj t	j
|d�¡d ‚w )NzXpydantic.v1 models are no longer supported by FastAPI. Please update the response model Ú.)Ú
annotationr   r+   )r,   r(   r*   )r)   )r   r   r   r   r   r   ÚfastapiÚ
exceptionsÚFastAPIErrorÚ_invalid_args_messageÚformat)r(   r)   r   r*   r+   r,   r   r   r    Úcreate_model_field:   s    ÿÿ
ÿþÿr5   Úmethodc                 C   s@   t jdtdd� | › |› �}t dd|¡}|› d| ¡ › �}|S )Nzrfastapi.utils.generate_operation_id_for_path() was deprecated, it is not used internally, and will be removed sooné   )ÚmessageÚcategoryÚ
stacklevelú\WÚ_)ÚwarningsÚwarnr   r$   ÚsubÚlower)r(   r"   r6   Úoperation_idr   r   r    Úgenerate_operation_id_for_pathP   s   ürB   Úrouter   c                 C   sH   | j › | j› �}t dd|¡}| jsJ ‚|› dt| jƒd  ¡ › �}|S )Nr;   r<   r   )r(   Úpath_formatr$   r?   ÚmethodsÚlistr@   )rC   rA   r   r   r    Úgenerate_unique_id_   s
   
rG   Ú	main_dictÚupdate_dictc                 C   sˆ   |  ¡ D ]=\}}|| v r t| | tƒr t|tƒr t| | |ƒ q|| v r=t| | tƒr=t|| tƒr=| | ||  | |< q|| |< qd S )N)ÚitemsÚ
isinstanceÚdictÚdeep_dict_updaterF   )rH   rI   ÚkeyÚvaluer   r   r    rM   g   s   ÿþÿþ
òrM   Ú
first_itemÚextra_itemsc                 G   s*   | f| }|D ]}t |tƒs|  S q| S )z×
    Pass items or `DefaultPlaceholder`s by descending priority.

    The first one to _not_ be a `DefaultPlaceholder` will be returned.

    Otherwise, the first item (a `DefaultPlaceholder`) will be returned.
    )rK   r	   )rP   rQ   rJ   Úitemr   r   r    Úget_value_or_defaulty   s   

ÿrS   )%r$   r=   Útypingr   r   r   r0   Úfastapi._compatr   r   r   r   Úfastapi.datastructuresr	   r
   Úfastapi.exceptionsr   r   Úpydantic.fieldsr   Ú_compatr   Úroutingr   r   ÚstrÚboolr!   r#   r&   r3   r5   rB   rG   rL   rM   rS   r   r   r   r    Ú<module>   sh    ÿúÿþýüûú
ùÿÿÿ
þ&ÿþý