@@ -714,16 +714,22 @@ class PydanticCustomError(ValueError):
714714 raise PydanticCustomError('custom_value_error', 'Value must be greater than {value}', {'value': 10, 'extra_context': 'extra_data'})
715715 return v
716716 ```
717-
718- Arguments:
719- error_type: The error type.
720- message_template: The message template.
721- context: The data to inject into the message template.
722717 """
723718
724719 def __init__ (
725- self , error_type : LiteralString , message_template : LiteralString , context : dict [str , Any ] | None = None , /
726- ) -> None : ...
720+ self , error_type : LiteralString , message_template : LiteralString , context : dict [str , Any ] | None = None
721+ ) -> None :
722+ """Initializes the `PydanticCustomError`.
723+
724+ Arguments:
725+ error_type: The error type.
726+ message_template: The message template.
727+ context: The data to inject into the message template.
728+ """
729+
730+ def __new__ (
731+ cls , error_type : LiteralString , message_template : LiteralString , context : dict [str , Any ] | None = None
732+ ) -> Self : ...
727733 @property
728734 def context (self ) -> dict [str , Any ] | None :
729735 """Values which are required to render the error message, and could hence be useful in passing error data forward."""
@@ -751,16 +757,20 @@ class PydanticKnownError(ValueError):
751757
752758 def custom_validator(v) -> None:
753759 if v <= 10:
754- raise PydanticKnownError('greater_than', {'gt': 10})
760+ raise PydanticKnownError(error_type= 'greater_than', context= {'gt': 10})
755761 return v
756762 ```
757-
758- Arguments:
759- error_type: The error type.
760- context: The data to inject into the message template.
761763 """
762764
763- def __init__ (self , error_type : ErrorType , context : dict [str , Any ] | None = None , / ) -> None : ...
765+ def __init__ (self , error_type : ErrorType , context : dict [str , Any ] | None = None ) -> None :
766+ """Initializes the `PydanticKnownError`.
767+
768+ Arguments:
769+ error_type: The error type.
770+ context: The data to inject into the message template.
771+ """
772+
773+ def __new__ (cls , error_type : ErrorType , context : dict [str , Any ] | None = None ) -> Self : ...
764774 @property
765775 def context (self ) -> dict [str , Any ] | None :
766776 """Values which are required to render the error message, and could hence be useful in passing error data forward."""
@@ -860,12 +870,16 @@ class PydanticSerializationError(ValueError):
860870 """An error raised when an issue occurs during serialization.
861871
862872 In custom serializers, this error can be used to indicate that serialization has failed.
863-
864- Arguments:
865- message: The message associated with the error.
866873 """
867874
868- def __init__ (self , message : str , / ) -> None : ...
875+ def __init__ (self , message : str ) -> None :
876+ """Initializes the `PydanticSerializationError`.
877+
878+ Arguments:
879+ message: The message associated with the error.
880+ """
881+
882+ def __new__ (cls , message : str ) -> Self : ...
869883
870884@final
871885class PydanticSerializationUnexpectedValue (ValueError ):
@@ -904,12 +918,16 @@ class PydanticSerializationUnexpectedValue(ValueError):
904918
905919 This is often used internally in `pydantic-core` when unexpected types are encountered during serialization,
906920 but it can also be used by users in custom serializers, as seen above.
907-
908- Arguments:
909- message: The message associated with the unexpected value.
910921 """
911922
912- def __init__ (self , message : str , / ) -> None : ...
923+ def __init__ (self , message : str ) -> None :
924+ """Initializes the `PydanticSerializationUnexpectedValue`.
925+
926+ Arguments:
927+ message: The message associated with the unexpected value.
928+ """
929+
930+ def __new__ (cls , message : str | None = None ) -> Self : ...
913931
914932@final
915933class ArgsKwargs :
0 commit comments