opt
/
hc_python
/
lib
/
python3.12
/
site-packages
/
pydantic
/
Go to Home Directory
+
Upload
Create File
root@0UT1S:~$
Execute
By Order of Mr.0UT1S
[DIR] ..
N/A
[DIR] __pycache__
N/A
[DIR] _internal
N/A
[DIR] deprecated
N/A
[DIR] experimental
N/A
[DIR] plugin
N/A
[DIR] v1
N/A
__init__.py
13.60 KB
Rename
Delete
_migration.py
11.63 KB
Rename
Delete
alias_generators.py
2.07 KB
Rename
Delete
aliases.py
4.71 KB
Rename
Delete
annotated_handlers.py
4.25 KB
Rename
Delete
class_validators.py
148 bytes
Rename
Delete
color.py
20.99 KB
Rename
Delete
config.py
34.29 KB
Rename
Delete
dataclasses.py
13.58 KB
Rename
Delete
datetime_parse.py
150 bytes
Rename
Delete
decorator.py
145 bytes
Rename
Delete
env_settings.py
148 bytes
Rename
Delete
error_wrappers.py
150 bytes
Rename
Delete
errors.py
4.72 KB
Rename
Delete
fields.py
50.53 KB
Rename
Delete
functional_serializers.py
14.27 KB
Rename
Delete
functional_validators.py
23.66 KB
Rename
Delete
generics.py
144 bytes
Rename
Delete
json.py
140 bytes
Rename
Delete
json_schema.py
103.81 KB
Rename
Delete
main.py
68.46 KB
Rename
Delete
mypy.py
55.64 KB
Rename
Delete
networks.py
22.18 KB
Rename
Delete
parse.py
141 bytes
Rename
Delete
py.typed
0 bytes
Rename
Delete
root_model.py
6.05 KB
Rename
Delete
schema.py
142 bytes
Rename
Delete
tools.py
141 bytes
Rename
Delete
type_adapter.py
24.39 KB
Rename
Delete
types.py
93.50 KB
Rename
Delete
typing.py
138 bytes
Rename
Delete
utils.py
141 bytes
Rename
Delete
validate_call_decorator.py
2.08 KB
Rename
Delete
validators.py
146 bytes
Rename
Delete
version.py
2.38 KB
Rename
Delete
warnings.py
2.65 KB
Rename
Delete
"""Pydantic-specific errors.""" from __future__ import annotations as _annotations import re from typing_extensions import Literal, Self from ._migration import getattr_migration from .version import version_short __all__ = ( 'PydanticUserError', 'PydanticUndefinedAnnotation', 'PydanticImportError', 'PydanticSchemaGenerationError', 'PydanticInvalidForJsonSchema', 'PydanticErrorCodes', ) # We use this URL to allow for future flexibility about how we host the docs, while allowing for Pydantic # code in the while with "old" URLs to still work. # 'u' refers to "user errors" - e.g. errors caused by developers using pydantic, as opposed to validation errors. DEV_ERROR_DOCS_URL = f'https://errors.pydantic.dev/{version_short()}/u/' PydanticErrorCodes = Literal[ 'class-not-fully-defined', 'custom-json-schema', 'decorator-missing-field', 'discriminator-no-field', 'discriminator-alias-type', 'discriminator-needs-literal', 'discriminator-alias', 'discriminator-validator', 'callable-discriminator-no-tag', 'typed-dict-version', 'model-field-overridden', 'model-field-missing-annotation', 'config-both', 'removed-kwargs', 'invalid-for-json-schema', 'json-schema-already-used', 'base-model-instantiated', 'undefined-annotation', 'schema-for-unknown-type', 'import-error', 'create-model-field-definitions', 'create-model-config-base', 'validator-no-fields', 'validator-invalid-fields', 'validator-instance-method', 'root-validator-pre-skip', 'model-serializer-instance-method', 'validator-field-config-info', 'validator-v1-signature', 'validator-signature', 'field-serializer-signature', 'model-serializer-signature', 'multiple-field-serializers', 'invalid_annotated_type', 'type-adapter-config-unused', 'root-model-extra', 'unevaluable-type-annotation', 'dataclass-init-false-extra-allow', 'clashing-init-and-init-var', 'model-config-invalid-field-name', 'with-config-on-model', 'dataclass-on-model', ] class PydanticErrorMixin: """A mixin class for common functionality shared by all Pydantic-specific errors. Attributes: message: A message describing the error. code: An optional error code from PydanticErrorCodes enum. """ def __init__(self, message: str, *, code: PydanticErrorCodes | None) -> None: self.message = message self.code = code def __str__(self) -> str: if self.code is None: return self.message else: return f'{self.message}\n\nFor further information visit {DEV_ERROR_DOCS_URL}{self.code}' class PydanticUserError(PydanticErrorMixin, TypeError): """An error raised due to incorrect use of Pydantic.""" class PydanticUndefinedAnnotation(PydanticErrorMixin, NameError): """A subclass of `NameError` raised when handling undefined annotations during `CoreSchema` generation. Attributes: name: Name of the error. message: Description of the error. """ def __init__(self, name: str, message: str) -> None: self.name = name super().__init__(message=message, code='undefined-annotation') @classmethod def from_name_error(cls, name_error: NameError) -> Self: """Convert a `NameError` to a `PydanticUndefinedAnnotation` error. Args: name_error: `NameError` to be converted. Returns: Converted `PydanticUndefinedAnnotation` error. """ try: name = name_error.name # type: ignore # python > 3.10 except AttributeError: name = re.search(r".*'(.+?)'", str(name_error)).group(1) # type: ignore[union-attr] return cls(name=name, message=str(name_error)) class PydanticImportError(PydanticErrorMixin, ImportError): """An error raised when an import fails due to module changes between V1 and V2. Attributes: message: Description of the error. """ def __init__(self, message: str) -> None: super().__init__(message, code='import-error') class PydanticSchemaGenerationError(PydanticUserError): """An error raised during failures to generate a `CoreSchema` for some type. Attributes: message: Description of the error. """ def __init__(self, message: str) -> None: super().__init__(message, code='schema-for-unknown-type') class PydanticInvalidForJsonSchema(PydanticUserError): """An error raised during failures to generate a JSON schema for some `CoreSchema`. Attributes: message: Description of the error. """ def __init__(self, message: str) -> None: super().__init__(message, code='invalid-for-json-schema') __getattr__ = getattr_migration(__name__)
Save