| from importlib import import_module |
| from typing import TYPE_CHECKING |
| from warnings import warn |
|
|
| from ._migration import getattr_migration |
| from .version import VERSION, _ensure_pydantic_core_version |
|
|
| _ensure_pydantic_core_version() |
| del _ensure_pydantic_core_version |
|
|
| if TYPE_CHECKING: |
| |
| |
| import pydantic_core |
| from pydantic_core.core_schema import ( |
| FieldSerializationInfo, |
| SerializationInfo, |
| SerializerFunctionWrapHandler, |
| ValidationInfo, |
| ValidatorFunctionWrapHandler, |
| ) |
|
|
| from . import dataclasses |
| from .aliases import AliasChoices, AliasGenerator, AliasPath |
| from .annotated_handlers import GetCoreSchemaHandler, GetJsonSchemaHandler |
| from .config import ConfigDict, with_config |
| from .errors import * |
| from .fields import Field, PrivateAttr, computed_field |
| from .functional_serializers import ( |
| PlainSerializer, |
| SerializeAsAny, |
| WrapSerializer, |
| field_serializer, |
| model_serializer, |
| ) |
| from .functional_validators import ( |
| AfterValidator, |
| BeforeValidator, |
| InstanceOf, |
| ModelWrapValidatorHandler, |
| PlainValidator, |
| SkipValidation, |
| ValidateAs, |
| WrapValidator, |
| field_validator, |
| model_validator, |
| ) |
| from .json_schema import WithJsonSchema |
| from .main import * |
| from .networks import * |
| from .type_adapter import TypeAdapter |
| from .types import * |
| from .validate_call_decorator import validate_call |
| from .warnings import ( |
| PydanticDeprecatedSince20, |
| PydanticDeprecatedSince26, |
| PydanticDeprecatedSince29, |
| PydanticDeprecatedSince210, |
| PydanticDeprecatedSince211, |
| PydanticDeprecatedSince212, |
| PydanticDeprecationWarning, |
| PydanticExperimentalWarning, |
| ) |
|
|
| |
| ValidationError = pydantic_core.ValidationError |
| from .deprecated.class_validators import root_validator, validator |
| from .deprecated.config import BaseConfig, Extra |
| from .deprecated.tools import * |
| from .root_model import RootModel |
|
|
| __version__ = VERSION |
| __all__ = ( |
| |
| 'dataclasses', |
| |
| 'field_validator', |
| 'model_validator', |
| 'AfterValidator', |
| 'BeforeValidator', |
| 'PlainValidator', |
| 'WrapValidator', |
| 'SkipValidation', |
| 'ValidateAs', |
| 'InstanceOf', |
| 'ModelWrapValidatorHandler', |
| |
| 'WithJsonSchema', |
| |
| 'root_validator', |
| 'validator', |
| |
| 'field_serializer', |
| 'model_serializer', |
| 'PlainSerializer', |
| 'SerializeAsAny', |
| 'WrapSerializer', |
| |
| 'ConfigDict', |
| 'with_config', |
| |
| 'BaseConfig', |
| 'Extra', |
| |
| 'validate_call', |
| |
| 'PydanticErrorCodes', |
| 'PydanticUserError', |
| 'PydanticSchemaGenerationError', |
| 'PydanticImportError', |
| 'PydanticUndefinedAnnotation', |
| 'PydanticInvalidForJsonSchema', |
| 'PydanticForbiddenQualifier', |
| |
| 'Field', |
| 'computed_field', |
| 'PrivateAttr', |
| |
| 'AliasChoices', |
| 'AliasGenerator', |
| 'AliasPath', |
| |
| 'BaseModel', |
| 'create_model', |
| |
| 'AnyUrl', |
| 'AnyHttpUrl', |
| 'FileUrl', |
| 'HttpUrl', |
| 'FtpUrl', |
| 'WebsocketUrl', |
| 'AnyWebsocketUrl', |
| 'UrlConstraints', |
| 'EmailStr', |
| 'NameEmail', |
| 'IPvAnyAddress', |
| 'IPvAnyInterface', |
| 'IPvAnyNetwork', |
| 'PostgresDsn', |
| 'CockroachDsn', |
| 'AmqpDsn', |
| 'RedisDsn', |
| 'MongoDsn', |
| 'KafkaDsn', |
| 'NatsDsn', |
| 'MySQLDsn', |
| 'MariaDBDsn', |
| 'ClickHouseDsn', |
| 'SnowflakeDsn', |
| 'validate_email', |
| |
| 'RootModel', |
| |
| 'parse_obj_as', |
| 'schema_of', |
| 'schema_json_of', |
| |
| 'Strict', |
| 'StrictStr', |
| 'conbytes', |
| 'conlist', |
| 'conset', |
| 'confrozenset', |
| 'constr', |
| 'StringConstraints', |
| 'ImportString', |
| 'conint', |
| 'PositiveInt', |
| 'NegativeInt', |
| 'NonNegativeInt', |
| 'NonPositiveInt', |
| 'confloat', |
| 'PositiveFloat', |
| 'NegativeFloat', |
| 'NonNegativeFloat', |
| 'NonPositiveFloat', |
| 'FiniteFloat', |
| 'condecimal', |
| 'condate', |
| 'UUID1', |
| 'UUID3', |
| 'UUID4', |
| 'UUID5', |
| 'UUID6', |
| 'UUID7', |
| 'UUID8', |
| 'FilePath', |
| 'DirectoryPath', |
| 'NewPath', |
| 'Json', |
| 'Secret', |
| 'SecretStr', |
| 'SecretBytes', |
| 'SocketPath', |
| 'StrictBool', |
| 'StrictBytes', |
| 'StrictInt', |
| 'StrictFloat', |
| 'PaymentCardNumber', |
| 'ByteSize', |
| 'PastDate', |
| 'FutureDate', |
| 'PastDatetime', |
| 'FutureDatetime', |
| 'AwareDatetime', |
| 'NaiveDatetime', |
| 'AllowInfNan', |
| 'EncoderProtocol', |
| 'EncodedBytes', |
| 'EncodedStr', |
| 'Base64Encoder', |
| 'Base64Bytes', |
| 'Base64Str', |
| 'Base64UrlBytes', |
| 'Base64UrlStr', |
| 'GetPydanticSchema', |
| 'Tag', |
| 'Discriminator', |
| 'JsonValue', |
| 'FailFast', |
| |
| 'TypeAdapter', |
| |
| '__version__', |
| 'VERSION', |
| |
| 'PydanticDeprecatedSince20', |
| 'PydanticDeprecatedSince26', |
| 'PydanticDeprecatedSince29', |
| 'PydanticDeprecatedSince210', |
| 'PydanticDeprecatedSince211', |
| 'PydanticDeprecatedSince212', |
| 'PydanticDeprecationWarning', |
| 'PydanticExperimentalWarning', |
| |
| 'GetCoreSchemaHandler', |
| 'GetJsonSchemaHandler', |
| |
| 'ValidationError', |
| 'ValidationInfo', |
| 'SerializationInfo', |
| 'ValidatorFunctionWrapHandler', |
| 'FieldSerializationInfo', |
| 'SerializerFunctionWrapHandler', |
| 'OnErrorOmit', |
| ) |
|
|
| |
| _dynamic_imports: 'dict[str, tuple[str, str]]' = { |
| 'dataclasses': (__spec__.parent, '__module__'), |
| |
| 'field_validator': (__spec__.parent, '.functional_validators'), |
| 'model_validator': (__spec__.parent, '.functional_validators'), |
| 'AfterValidator': (__spec__.parent, '.functional_validators'), |
| 'BeforeValidator': (__spec__.parent, '.functional_validators'), |
| 'PlainValidator': (__spec__.parent, '.functional_validators'), |
| 'WrapValidator': (__spec__.parent, '.functional_validators'), |
| 'SkipValidation': (__spec__.parent, '.functional_validators'), |
| 'InstanceOf': (__spec__.parent, '.functional_validators'), |
| 'ValidateAs': (__spec__.parent, '.functional_validators'), |
| 'ModelWrapValidatorHandler': (__spec__.parent, '.functional_validators'), |
| |
| 'WithJsonSchema': (__spec__.parent, '.json_schema'), |
| |
| 'field_serializer': (__spec__.parent, '.functional_serializers'), |
| 'model_serializer': (__spec__.parent, '.functional_serializers'), |
| 'PlainSerializer': (__spec__.parent, '.functional_serializers'), |
| 'SerializeAsAny': (__spec__.parent, '.functional_serializers'), |
| 'WrapSerializer': (__spec__.parent, '.functional_serializers'), |
| |
| 'ConfigDict': (__spec__.parent, '.config'), |
| 'with_config': (__spec__.parent, '.config'), |
| |
| 'validate_call': (__spec__.parent, '.validate_call_decorator'), |
| |
| 'PydanticErrorCodes': (__spec__.parent, '.errors'), |
| 'PydanticUserError': (__spec__.parent, '.errors'), |
| 'PydanticSchemaGenerationError': (__spec__.parent, '.errors'), |
| 'PydanticImportError': (__spec__.parent, '.errors'), |
| 'PydanticUndefinedAnnotation': (__spec__.parent, '.errors'), |
| 'PydanticInvalidForJsonSchema': (__spec__.parent, '.errors'), |
| 'PydanticForbiddenQualifier': (__spec__.parent, '.errors'), |
| |
| 'Field': (__spec__.parent, '.fields'), |
| 'computed_field': (__spec__.parent, '.fields'), |
| 'PrivateAttr': (__spec__.parent, '.fields'), |
| |
| 'AliasChoices': (__spec__.parent, '.aliases'), |
| 'AliasGenerator': (__spec__.parent, '.aliases'), |
| 'AliasPath': (__spec__.parent, '.aliases'), |
| |
| 'BaseModel': (__spec__.parent, '.main'), |
| 'create_model': (__spec__.parent, '.main'), |
| |
| 'AnyUrl': (__spec__.parent, '.networks'), |
| 'AnyHttpUrl': (__spec__.parent, '.networks'), |
| 'FileUrl': (__spec__.parent, '.networks'), |
| 'HttpUrl': (__spec__.parent, '.networks'), |
| 'FtpUrl': (__spec__.parent, '.networks'), |
| 'WebsocketUrl': (__spec__.parent, '.networks'), |
| 'AnyWebsocketUrl': (__spec__.parent, '.networks'), |
| 'UrlConstraints': (__spec__.parent, '.networks'), |
| 'EmailStr': (__spec__.parent, '.networks'), |
| 'NameEmail': (__spec__.parent, '.networks'), |
| 'IPvAnyAddress': (__spec__.parent, '.networks'), |
| 'IPvAnyInterface': (__spec__.parent, '.networks'), |
| 'IPvAnyNetwork': (__spec__.parent, '.networks'), |
| 'PostgresDsn': (__spec__.parent, '.networks'), |
| 'CockroachDsn': (__spec__.parent, '.networks'), |
| 'AmqpDsn': (__spec__.parent, '.networks'), |
| 'RedisDsn': (__spec__.parent, '.networks'), |
| 'MongoDsn': (__spec__.parent, '.networks'), |
| 'KafkaDsn': (__spec__.parent, '.networks'), |
| 'NatsDsn': (__spec__.parent, '.networks'), |
| 'MySQLDsn': (__spec__.parent, '.networks'), |
| 'MariaDBDsn': (__spec__.parent, '.networks'), |
| 'ClickHouseDsn': (__spec__.parent, '.networks'), |
| 'SnowflakeDsn': (__spec__.parent, '.networks'), |
| 'validate_email': (__spec__.parent, '.networks'), |
| |
| 'RootModel': (__spec__.parent, '.root_model'), |
| |
| 'Strict': (__spec__.parent, '.types'), |
| 'StrictStr': (__spec__.parent, '.types'), |
| 'conbytes': (__spec__.parent, '.types'), |
| 'conlist': (__spec__.parent, '.types'), |
| 'conset': (__spec__.parent, '.types'), |
| 'confrozenset': (__spec__.parent, '.types'), |
| 'constr': (__spec__.parent, '.types'), |
| 'StringConstraints': (__spec__.parent, '.types'), |
| 'ImportString': (__spec__.parent, '.types'), |
| 'conint': (__spec__.parent, '.types'), |
| 'PositiveInt': (__spec__.parent, '.types'), |
| 'NegativeInt': (__spec__.parent, '.types'), |
| 'NonNegativeInt': (__spec__.parent, '.types'), |
| 'NonPositiveInt': (__spec__.parent, '.types'), |
| 'confloat': (__spec__.parent, '.types'), |
| 'PositiveFloat': (__spec__.parent, '.types'), |
| 'NegativeFloat': (__spec__.parent, '.types'), |
| 'NonNegativeFloat': (__spec__.parent, '.types'), |
| 'NonPositiveFloat': (__spec__.parent, '.types'), |
| 'FiniteFloat': (__spec__.parent, '.types'), |
| 'condecimal': (__spec__.parent, '.types'), |
| 'condate': (__spec__.parent, '.types'), |
| 'UUID1': (__spec__.parent, '.types'), |
| 'UUID3': (__spec__.parent, '.types'), |
| 'UUID4': (__spec__.parent, '.types'), |
| 'UUID5': (__spec__.parent, '.types'), |
| 'UUID6': (__spec__.parent, '.types'), |
| 'UUID7': (__spec__.parent, '.types'), |
| 'UUID8': (__spec__.parent, '.types'), |
| 'FilePath': (__spec__.parent, '.types'), |
| 'DirectoryPath': (__spec__.parent, '.types'), |
| 'NewPath': (__spec__.parent, '.types'), |
| 'Json': (__spec__.parent, '.types'), |
| 'Secret': (__spec__.parent, '.types'), |
| 'SecretStr': (__spec__.parent, '.types'), |
| 'SecretBytes': (__spec__.parent, '.types'), |
| 'StrictBool': (__spec__.parent, '.types'), |
| 'StrictBytes': (__spec__.parent, '.types'), |
| 'StrictInt': (__spec__.parent, '.types'), |
| 'StrictFloat': (__spec__.parent, '.types'), |
| 'PaymentCardNumber': (__spec__.parent, '.types'), |
| 'ByteSize': (__spec__.parent, '.types'), |
| 'PastDate': (__spec__.parent, '.types'), |
| 'SocketPath': (__spec__.parent, '.types'), |
| 'FutureDate': (__spec__.parent, '.types'), |
| 'PastDatetime': (__spec__.parent, '.types'), |
| 'FutureDatetime': (__spec__.parent, '.types'), |
| 'AwareDatetime': (__spec__.parent, '.types'), |
| 'NaiveDatetime': (__spec__.parent, '.types'), |
| 'AllowInfNan': (__spec__.parent, '.types'), |
| 'EncoderProtocol': (__spec__.parent, '.types'), |
| 'EncodedBytes': (__spec__.parent, '.types'), |
| 'EncodedStr': (__spec__.parent, '.types'), |
| 'Base64Encoder': (__spec__.parent, '.types'), |
| 'Base64Bytes': (__spec__.parent, '.types'), |
| 'Base64Str': (__spec__.parent, '.types'), |
| 'Base64UrlBytes': (__spec__.parent, '.types'), |
| 'Base64UrlStr': (__spec__.parent, '.types'), |
| 'GetPydanticSchema': (__spec__.parent, '.types'), |
| 'Tag': (__spec__.parent, '.types'), |
| 'Discriminator': (__spec__.parent, '.types'), |
| 'JsonValue': (__spec__.parent, '.types'), |
| 'OnErrorOmit': (__spec__.parent, '.types'), |
| 'FailFast': (__spec__.parent, '.types'), |
| |
| 'TypeAdapter': (__spec__.parent, '.type_adapter'), |
| |
| 'PydanticDeprecatedSince20': (__spec__.parent, '.warnings'), |
| 'PydanticDeprecatedSince26': (__spec__.parent, '.warnings'), |
| 'PydanticDeprecatedSince29': (__spec__.parent, '.warnings'), |
| 'PydanticDeprecatedSince210': (__spec__.parent, '.warnings'), |
| 'PydanticDeprecatedSince211': (__spec__.parent, '.warnings'), |
| 'PydanticDeprecatedSince212': (__spec__.parent, '.warnings'), |
| 'PydanticDeprecationWarning': (__spec__.parent, '.warnings'), |
| 'PydanticExperimentalWarning': (__spec__.parent, '.warnings'), |
| |
| 'GetCoreSchemaHandler': (__spec__.parent, '.annotated_handlers'), |
| 'GetJsonSchemaHandler': (__spec__.parent, '.annotated_handlers'), |
| |
| 'ValidationError': ('pydantic_core', '.'), |
| 'ValidationInfo': ('pydantic_core', '.core_schema'), |
| 'SerializationInfo': ('pydantic_core', '.core_schema'), |
| 'ValidatorFunctionWrapHandler': ('pydantic_core', '.core_schema'), |
| 'FieldSerializationInfo': ('pydantic_core', '.core_schema'), |
| 'SerializerFunctionWrapHandler': ('pydantic_core', '.core_schema'), |
| |
| 'root_validator': (__spec__.parent, '.deprecated.class_validators'), |
| 'validator': (__spec__.parent, '.deprecated.class_validators'), |
| 'BaseConfig': (__spec__.parent, '.deprecated.config'), |
| 'Extra': (__spec__.parent, '.deprecated.config'), |
| 'parse_obj_as': (__spec__.parent, '.deprecated.tools'), |
| 'schema_of': (__spec__.parent, '.deprecated.tools'), |
| 'schema_json_of': (__spec__.parent, '.deprecated.tools'), |
| |
| 'FieldValidationInfo': ('pydantic_core', '.core_schema'), |
| 'GenerateSchema': (__spec__.parent, '._internal._generate_schema'), |
| } |
| _deprecated_dynamic_imports = {'FieldValidationInfo', 'GenerateSchema'} |
|
|
| _getattr_migration = getattr_migration(__name__) |
|
|
|
|
| def __getattr__(attr_name: str) -> object: |
| if attr_name in _deprecated_dynamic_imports: |
| from pydantic.warnings import PydanticDeprecatedSince20 |
|
|
| warn( |
| f'Importing {attr_name} from `pydantic` is deprecated. This feature is either no longer supported, or is not public.', |
| PydanticDeprecatedSince20, |
| stacklevel=2, |
| ) |
|
|
| dynamic_attr = _dynamic_imports.get(attr_name) |
| if dynamic_attr is None: |
| return _getattr_migration(attr_name) |
|
|
| package, module_name = dynamic_attr |
|
|
| if module_name == '__module__': |
| result = import_module(f'.{attr_name}', package=package) |
| globals()[attr_name] = result |
| return result |
| else: |
| module = import_module(module_name, package=package) |
| result = getattr(module, attr_name) |
| g = globals() |
| for k, (_, v_module_name) in _dynamic_imports.items(): |
| if v_module_name == module_name and k not in _deprecated_dynamic_imports: |
| g[k] = getattr(module, k) |
| return result |
|
|
|
|
| def __dir__() -> list[str]: |
| return list(__all__) |
|
|