관리-도구
편집 파일: _signature.cpython-38.pyc
U /?�f� � @ s� d dl mZ d dlZd dlmZmZmZ d dlmZm Z m Z d dlmZ ddl mZ ddlmZ erpd d lmZ dddd �dd�Zddd�dd�Zddddd�dd�Zd!dddddd�dd �ZdS )"� )�annotationsN)� Parameter� Signature� signature)� TYPE_CHECKING�Any�Callable)�PydanticUndefined� )� ConfigWrapper)�is_valid_identifier� �� FieldInfo�strr )� field_name� field_info�returnc C s( ddd�dd�}||j �p&||j�p&| S )a� Extract the correct name to use for the field when generating a signature. Assuming the field has a valid alias, this will return the alias. Otherwise, it will return the field name. First priority is given to the validation_alias, then the alias, then the field name. Args: field_name: The name of the field field_info: The corresponding FieldInfo object. Returns: The correct name to use when generating a signature. r z str | None)�xr c S s t | t�rt| �r| S dS )zBReturn the alias if it is a valid alias and identifier, else None.N)� isinstancer r )r � r �K/opt/hc_python/lib/python3.8/site-packages/pydantic/_internal/_signature.py�_alias_if_valid s z2_field_name_for_signature.<locals>._alias_if_valid)�aliasZvalidation_alias)r r r r r r �_field_name_for_signature s r r )�paramr c C sp ddl m} | j}t||�rl| j}|dkr.t}|j}|tkrT|jtkrNtj }nt j}| j|t | j|�|d�S | S )z�Modify the signature for a parameter in a dataclass where the default value is a FieldInfo instance. Args: param (Parameter): The parameter Returns: Parameter: The custom processed parameter r r r )� annotation�name�default)�fieldsr r r r r r �default_factoryr �empty�dataclasses�_HAS_DEFAULT_FACTORY�replacer r )r r Z param_defaultr r r r r �_process_param_defaults% s"