Movatterモバイル変換


[0]ホーム

URL:


Skip to content
What's new — we've launchedPydantic Logfire🔥to help you monitor and understand yourPydantic validations.

Errors

Pydantic-specific errors.

PydanticErrorMixin

PydanticErrorMixin(message:str,*,code:PydanticErrorCodes|None)

A mixin class for common functionality shared by all Pydantic-specific errors.

Attributes:

NameTypeDescription
message

A message describing the error.

code

An optional error code from PydanticErrorCodes enum.

Source code inpydantic/errors.py
909192
def__init__(self,message:str,*,code:PydanticErrorCodes|None)->None:self.message=messageself.code=code

PydanticUserError

PydanticUserError(message:str,*,code:PydanticErrorCodes|None)

Bases:PydanticErrorMixin,TypeError

An error raised due to incorrect use of Pydantic.

Source code inpydantic/errors.py
909192
def__init__(self,message:str,*,code:PydanticErrorCodes|None)->None:self.message=messageself.code=code

PydanticUndefinedAnnotation

PydanticUndefinedAnnotation(name:str,message:str)

Bases:PydanticErrorMixin,NameError

A subclass ofNameError raised when handling undefined annotations duringCoreSchema generation.

Attributes:

NameTypeDescription
name

Name of the error.

message

Description of the error.

Source code inpydantic/errors.py
113114115
def__init__(self,name:str,message:str)->None:self.name=namesuper().__init__(message=message,code='undefined-annotation')

from_name_errorclassmethod

from_name_error(name_error:NameError)->Self

Convert aNameError to aPydanticUndefinedAnnotation error.

Parameters:

NameTypeDescriptionDefault
name_errorNameError

NameError to be converted.

required

Returns:

TypeDescription
Self

ConvertedPydanticUndefinedAnnotation error.

Source code inpydantic/errors.py
117118119120121122123124125126127128129130131
@classmethoddeffrom_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.10exceptAttributeError:name=re.search(r".*'(.+?)'",str(name_error)).group(1)# type: ignore[union-attr]returncls(name=name,message=str(name_error))

PydanticImportError

PydanticImportError(message:str)

Bases:PydanticErrorMixin,ImportError

An error raised when an import fails due to module changes between V1 and V2.

Attributes:

NameTypeDescription
message

Description of the error.

Source code inpydantic/errors.py
141142
def__init__(self,message:str)->None:super().__init__(message,code='import-error')

PydanticSchemaGenerationError

PydanticSchemaGenerationError(message:str)

Bases:PydanticUserError

An error raised during failures to generate aCoreSchema for some type.

Attributes:

NameTypeDescription
message

Description of the error.

Source code inpydantic/errors.py
152153
def__init__(self,message:str)->None:super().__init__(message,code='schema-for-unknown-type')

PydanticInvalidForJsonSchema

PydanticInvalidForJsonSchema(message:str)

Bases:PydanticUserError

An error raised during failures to generate a JSON schema for someCoreSchema.

Attributes:

NameTypeDescription
message

Description of the error.

Source code inpydantic/errors.py
163164
def__init__(self,message:str)->None:super().__init__(message,code='invalid-for-json-schema')

PydanticForbiddenQualifier

PydanticForbiddenQualifier(qualifier:Qualifier,annotation:Any)

Bases:PydanticUserError

An error raised if a forbidden type qualifier is found in a type annotation.

Source code inpydantic/errors.py
179180181182183184185186
def__init__(self,qualifier:Qualifier,annotation:Any)->None:super().__init__(message=(f'The annotation{_repr.display_as_type(annotation)!r} contains the{self._qualifier_repr_map[qualifier]!r} 'f'type qualifier, which is invalid in the context it is defined.'),code=None,)

[8]ページ先頭

©2009-2025 Movatter.jp