Skip to main content

AliasPath

A data class used by validation_alias as a convenience to create aliases.

Attributes

AttributeTypeDescription
path`list[intstr]`

Constructor

Signature

def AliasPath(
first_arg: str,
*args: str | int
) - > None

Parameters

NameTypeDescription
first_argstrThe first element of the alias path.
*args`strint`

Signature

def AliasPath(
first_arg: str,
*args: str | int
)

Parameters

NameTypeDescription
first_argstrThe initial segment of the alias path, typically a dictionary key.
*args`strint`

Methods


convert_to_aliases()

@classmethod
def convert_to_aliases() - > list[str | int]

Converts arguments to a list of string or integer aliases.

Returns

TypeDescription
`list[strint]`

search_dict_for_path()

@classmethod
def search_dict_for_path(
d: dict
) - > Any

Searches a dictionary for the path specified by the alias.

Parameters

NameTypeDescription
ddictThe source dictionary to traverse using the defined alias path segments.

Returns

TypeDescription
AnyThe value at the specified path, or PydanticUndefined if the path is not found.