MCPcopy
hub / github.com/pydantic/pydantic / get_unique_discriminator_alias

Function get_unique_discriminator_alias

pydantic/v1/utils.py:750–757  ·  view source on GitHub ↗

Validate that all aliases are the same and if that's the case return the alias

(all_aliases: Collection[str], discriminator_key: str)

Source from the content-addressed store, hash-verified

748
749
750def get_unique_discriminator_alias(all_aliases: Collection[str], discriminator_key: str) -> str:
751 """Validate that all aliases are the same and if that's the case return the alias"""
752 unique_aliases = set(all_aliases)
753 if len(unique_aliases) > 1:
754 raise ConfigError(
755 f'Aliases for discriminator {discriminator_key!r} must be the same (got {", ".join(sorted(all_aliases))})'
756 )
757 return unique_aliases.pop()
758
759
760def get_discriminator_alias_and_values(tp: Any, discriminator_key: str) -> Tuple[str, Tuple[str, ...]]:

Calls 1

ConfigErrorClass · 0.90

Tested by

no test coverage detected