Skip to content

Commit 4527b80

Browse files
authored
use __new__ in .pyi for Rust types (#743)
1 parent d08d269 commit 4527b80

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

python/pydantic_core/_pydantic_core.pyi

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class Some(Generic[_T]):
5858

5959
@final
6060
class SchemaValidator:
61-
def __init__(self, schema: CoreSchema, config: CoreConfig | None = None) -> None: ...
61+
def __new__(cls, schema: CoreSchema, config: CoreConfig | None = None) -> Self: ...
6262
@property
6363
def title(self) -> str: ...
6464
def validate_python(
@@ -103,7 +103,7 @@ _IncEx: TypeAlias = set[int] | set[str] | dict[int, _IncEx] | dict[str, _IncEx]
103103

104104
@final
105105
class SchemaSerializer:
106-
def __init__(self, schema: CoreSchema, config: CoreConfig | None = None) -> None: ...
106+
def __new__(cls, schema: CoreSchema, config: CoreConfig | None = None) -> Self: ...
107107
def to_python(
108108
self,
109109
value: Any,
@@ -164,7 +164,7 @@ def to_jsonable_python(
164164
) -> Any: ...
165165

166166
class Url(SupportsAllComparisons):
167-
def __init__(self, url: str) -> None: ...
167+
def __new__(cls, url: str) -> Self: ...
168168
@property
169169
def scheme(self) -> str: ...
170170
@property
@@ -189,7 +189,7 @@ class Url(SupportsAllComparisons):
189189
def __deepcopy__(self, memo: dict) -> str: ...
190190

191191
class MultiHostUrl(SupportsAllComparisons):
192-
def __init__(self, url: str) -> None: ...
192+
def __new__(cls, url: str) -> Self: ...
193193
@property
194194
def scheme(self) -> str: ...
195195
@property
@@ -233,9 +233,9 @@ class ValidationError(ValueError):
233233

234234
@final
235235
class PydanticCustomError(ValueError):
236-
def __init__(
237-
self, error_type: LiteralString, message_template: LiteralString, context: dict[str, Any] | None = None
238-
) -> None: ...
236+
def __new__(
237+
cls, error_type: LiteralString, message_template: LiteralString, context: dict[str, Any] | None = None
238+
) -> Self: ...
239239
@property
240240
def context(self) -> dict[str, Any] | None: ...
241241
@property
@@ -246,9 +246,9 @@ class PydanticCustomError(ValueError):
246246

247247
@final
248248
class PydanticKnownError(ValueError):
249-
def __init__(
250-
self, error_type: ErrorType, context: dict[str, str | int | float | decimal.Decimal] | None = None
251-
) -> None: ...
249+
def __new__(
250+
cls, error_type: ErrorType, context: dict[str, str | int | float | decimal.Decimal] | None = None
251+
) -> Self: ...
252252
@property
253253
def context(self) -> dict[str, str | int | float] | None: ...
254254
@property
@@ -259,23 +259,23 @@ class PydanticKnownError(ValueError):
259259

260260
@final
261261
class PydanticOmit(Exception):
262-
def __new__(self) -> PydanticOmit: ...
262+
def __new__(cls) -> Self: ...
263263

264264
@final
265265
class PydanticUseDefault(Exception):
266-
def __new__(self) -> PydanticUseDefault: ...
266+
def __new__(cls) -> Self: ...
267267

268268
@final
269269
class PydanticSerializationError(ValueError):
270-
def __init__(self, message: str) -> None: ...
270+
def __new__(cls, message: str) -> Self: ...
271271

272272
@final
273273
class PydanticSerializationUnexpectedValue(ValueError):
274-
def __init__(self, message: str | None = None) -> None: ...
274+
def __new__(cls, message: str | None = None) -> Self: ...
275275

276276
@final
277277
class ArgsKwargs:
278-
def __init__(self, args: tuple[Any, ...], kwargs: dict[str, Any] | None = None) -> None: ...
278+
def __new__(cls, args: tuple[Any, ...], kwargs: dict[str, Any] | None = None) -> Self: ...
279279
@property
280280
def args(self) -> tuple[Any, ...]: ...
281281
@property

0 commit comments

Comments
 (0)