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 alias, then the validation_alias, then the field name. Args: fie
(field_name: str, field_info: FieldInfo)
| 24 | |
| 25 | |
| 26 | def _field_name_for_signature(field_name: str, field_info: FieldInfo) -> str: |
| 27 | """Extract the correct name to use for the field when generating a signature. |
| 28 | |
| 29 | Assuming the field has a valid alias, this will return the alias. Otherwise, it will return the field name. |
| 30 | First priority is given to the alias, then the validation_alias, then the field name. |
| 31 | |
| 32 | Args: |
| 33 | field_name: The name of the field |
| 34 | field_info: The corresponding FieldInfo object. |
| 35 | |
| 36 | Returns: |
| 37 | The correct name to use when generating a signature. |
| 38 | """ |
| 39 | if isinstance(field_info.alias, str) and is_valid_identifier(field_info.alias): |
| 40 | return field_info.alias |
| 41 | if isinstance(field_info.validation_alias, str) and is_valid_identifier(field_info.validation_alias): |
| 42 | return field_info.validation_alias |
| 43 | |
| 44 | return field_name |
| 45 | |
| 46 | |
| 47 | def _process_param_defaults(param: Parameter) -> Parameter: |
no test coverage detected