@@ -714,22 +714,16 @@ class PydanticCustomError(ValueError):
714
714
raise PydanticCustomError('custom_value_error', 'Value must be greater than {value}', {'value': 10, 'extra_context': 'extra_data'})
715
715
return v
716
716
```
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.
717
722
"""
718
723
719
724
def __init__ (
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 : ...
725
+ self , error_type : LiteralString , message_template : LiteralString , context : dict [str , Any ] | None = None , /
726
+ ) -> None : ...
733
727
@property
734
728
def context (self ) -> dict [str , Any ] | None :
735
729
"""Values which are required to render the error message, and could hence be useful in passing error data forward."""
@@ -757,20 +751,16 @@ class PydanticKnownError(ValueError):
757
751
758
752
def custom_validator(v) -> None:
759
753
if v <= 10:
760
- raise PydanticKnownError(error_type= 'greater_than', context= {'gt': 10})
754
+ raise PydanticKnownError('greater_than', {'gt': 10})
761
755
return v
762
756
```
763
- """
764
-
765
- def __init__ (self , error_type : ErrorType , context : dict [str , Any ] | None = None ) -> None :
766
- """Initializes the `PydanticKnownError`.
767
757
768
- Arguments:
769
- error_type: The error type.
770
- context: The data to inject into the message template.
771
- """
758
+ Arguments:
759
+ error_type: The error type.
760
+ context: The data to inject into the message template.
761
+ """
772
762
773
- def __new__ ( cls , error_type : ErrorType , context : dict [str , Any ] | None = None ) -> Self : ...
763
+ def __init__ ( self , error_type : ErrorType , context : dict [str , Any ] | None = None , / ) -> None : ...
774
764
@property
775
765
def context (self ) -> dict [str , Any ] | None :
776
766
"""Values which are required to render the error message, and could hence be useful in passing error data forward."""
@@ -870,16 +860,12 @@ class PydanticSerializationError(ValueError):
870
860
"""An error raised when an issue occurs during serialization.
871
861
872
862
In custom serializers, this error can be used to indicate that serialization has failed.
873
- """
874
-
875
- def __init__ (self , message : str ) -> None :
876
- """Initializes the `PydanticSerializationError`.
877
863
878
- Arguments:
879
- message: The message associated with the error.
880
- """
864
+ Arguments:
865
+ message: The message associated with the error.
866
+ """
881
867
882
- def __new__ ( cls , message : str ) -> Self : ...
868
+ def __init__ ( self , message : str , / ) -> None : ...
883
869
884
870
@final
885
871
class PydanticSerializationUnexpectedValue (ValueError ):
@@ -918,16 +904,12 @@ class PydanticSerializationUnexpectedValue(ValueError):
918
904
919
905
This is often used internally in `pydantic-core` when unexpected types are encountered during serialization,
920
906
but it can also be used by users in custom serializers, as seen above.
921
- """
922
-
923
- def __init__ (self , message : str ) -> None :
924
- """Initializes the `PydanticSerializationUnexpectedValue`.
925
907
926
- Arguments:
927
- message: The message associated with the unexpected value.
928
- """
908
+ Arguments:
909
+ message: The message associated with the unexpected value.
910
+ """
929
911
930
- def __new__ ( cls , message : str | None = None ) -> Self : ...
912
+ def __init__ ( self , message : str , / ) -> None : ...
931
913
932
914
@final
933
915
class ArgsKwargs :
0 commit comments