fBdZddlmZddlZddlmZmZmZddlm Z ddl m Z dZ ejdie jGd d Zejdie jGd d Zejdie jGd dZy)z!Support for alias configurations.) annotationsN)AnyCallableLiteral)PydanticUndefined)_internal_dataclass)AliasGenerator AliasPath AliasChoicesc4eZdZUdZded<ddZd dZd dZy) r zUsage docs: https://docs.pydantic.dev/2.9/concepts/alias#aliaspath-and-aliaschoices A data class used by `validation_alias` as a convenience to create aliases. Attributes: path: A list of string or integer aliases. zlist[int | str]pathc,|gt|z|_yN)listr)self first_argargss Y/var/lib/jenkins/workspace/mettalog/venv/lib/python3.12/site-packages/pydantic/aliases.py__init__zAliasPath.__init__sK$t*, c|jS)zvConverts arguments to a list of string or integer aliases. Returns: The list of aliases. )r)rs rconvert_to_aliaseszAliasPath.convert_to_aliasess yyrc|}|jD] }t|trtcS ||}"|S#tt t f$r tcYcSwxYw)zSearches a dictionary for the path specified by the alias. Returns: The value at the specified path, or `PydanticUndefined` if the path is not found. )r isinstancestrrKeyError IndexError TypeError)rdvks rsearch_dict_for_pathzAliasPath.search_dict_for_path&sZ A!S!(( )aD j)4 )(( )s4AAN)rrrz str | intreturnNone)r$zlist[str | int])r dictr$r)__name__ __module__ __qualname____doc____annotations__rrr#rrr r s -rr c,eZdZUdZded<ddZddZy) r zUsage docs: https://docs.pydantic.dev/2.9/concepts/alias#aliaspath-and-aliaschoices A data class used by `validation_alias` as a convenience to create aliases. Attributes: choices: A list containing a string or `AliasPath`. zlist[str | AliasPath]choicesc,|gt|z|_yr)rr.)r first_choicer.s rrzAliasChoices.__init__Ds$~W 5 rcg}|jD]D}t|tr |j|j 3|j|gF|S)zConverts arguments to a list of lists containing string or integer aliases. Returns: The list of aliases. )r.rr appendr)raliasescs rrzAliasChoices.convert_to_aliasesGsK *,A!Y'q3356s#  rN)r0str | AliasPathr.r5r$r%)r$zlist[list[str | int]])r'r(r)r*r+rrr,rrr r 8s#"6 rr c\eZdZUdZdZded<dZded<dZded< d dZd d Z y) r aUsage docs: https://docs.pydantic.dev/2.9/concepts/alias#using-an-aliasgenerator A data class used by `alias_generator` as a convenience to create various aliases. Attributes: alias: A callable that takes a field name and returns an alias for it. validation_alias: A callable that takes a field name and returns a validation alias for it. serialization_alias: A callable that takes a field name and returns a serialization alias for it. NzCallable[[str], str] | Nonealiasz6Callable[[str], str | AliasPath | AliasChoices] | Nonevalidation_aliasserialization_aliasc |d}t||x}r+||}|r!t||std|d|d|d|S)zGenerate an alias of the specified kind. Returns None if the alias generator is None. Raises: TypeError: If the alias generator produces an invalid type. Nz Invalid `z ` type. `z!` generator must produce one of ``)getattrrr)r alias_kind allowed_types field_namer7alias_generators r_generate_aliaszAliasGenerator._generate_aliasfsa%dJ7 7? 7#J/EZ}= |9ZL@aboappqr rc|jdtf|}|jdtttf|}|jdtf|}|||fS)zGenerate `alias`, `validation_alias`, and `serialization_alias` for a field. Returns: A tuple of three aliases - validation, alias, and serialization. r7r8r9)rArr r )rr?r7r8r9s rgenerate_aliaseszAliasGenerator.generate_aliaseszsa $$WsfjA//0BS,XaDbdno"223H3&R\]&(;;;r)r=z;Literal['alias', 'validation_alias', 'serialization_alias']r>zrLs'"))+* 98,778%%9%P8,7789:8,778-<-<9-