Aliases
Support for alias configurations.
AliasPath
dataclass
¶
Usage Documentation
A data class used by validation_alias as a convenience to create aliases.
属性:
| 名称 | 类型 | 描述 |
|---|---|---|
path |
list[int | str]
|
A list of string or integer aliases. |
Source code in .venv/lib/python3.13/site-packages/pydantic/aliases.py
28 29 | |
convert_to_aliases ¶
Converts arguments to a list of string or integer aliases.
返回:
| 类型 | 描述 |
|---|---|
list[str | int]
|
The list of aliases. |
源代码位于: .venv/lib/python3.13/site-packages/pydantic/aliases.py
31 32 33 34 35 36 37 | |
search_dict_for_path ¶
Searches a dictionary for the path specified by the alias.
返回:
| 类型 | 描述 |
|---|---|
Any
|
The value at the specified path, or |
源代码位于: .venv/lib/python3.13/site-packages/pydantic/aliases.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | |
AliasChoices
dataclass
¶
Usage Documentation
A data class used by validation_alias as a convenience to create aliases.
属性:
| 名称 | 类型 | 描述 |
|---|---|---|
choices |
list[str | AliasPath]
|
A list containing a string or |
Source code in .venv/lib/python3.13/site-packages/pydantic/aliases.py
70 71 | |
convert_to_aliases ¶
Converts arguments to a list of lists containing string or integer aliases.
返回:
| 类型 | 描述 |
|---|---|
list[list[str | int]]
|
The list of aliases. |
源代码位于: .venv/lib/python3.13/site-packages/pydantic/aliases.py
73 74 75 76 77 78 79 80 81 82 83 84 85 | |
AliasGenerator
dataclass
¶
AliasGenerator(alias: Callable[[str], str] | None = None, validation_alias: Callable[[str], str | AliasPath | AliasChoices] | None = None, serialization_alias: Callable[[str], str] | None = None)
Usage Documentation
A data class used by alias_generator as a convenience to create various aliases.
属性:
| 名称 | 类型 | 描述 |
|---|---|---|
alias |
Callable[[str], str] | None
|
A callable that takes a field name and returns an alias for it. |
validation_alias |
Callable[[str], str | AliasPath | AliasChoices] | None
|
A callable that takes a field name and returns a validation alias for it. |
serialization_alias |
Callable[[str], str] | None
|
A callable that takes a field name and returns a serialization alias for it. |
generate_aliases ¶
generate_aliases(field_name: str) -> tuple[str | None, str | AliasPath | AliasChoices | None, str | None]
Generate alias, validation_alias, and serialization_alias for a field.
返回:
| 类型 | 描述 |
|---|---|
tuple[str | None, str | AliasPath | AliasChoices | None, str | None]
|
A tuple of three aliases - validation, alias, and serialization. |
源代码位于: .venv/lib/python3.13/site-packages/pydantic/aliases.py
125 126 127 128 129 130 131 132 133 134 135 | |