Skip to content

Commit fef791c

Browse files
committed
Use from __future__ import annotations instead of string type hints in python/pydantic_core/_pydantic_core.pyi
1 parent f43fab3 commit fef791c

File tree

1 file changed

+54
-52
lines changed

1 file changed

+54
-52
lines changed

python/pydantic_core/_pydantic_core.pyi

Lines changed: 54 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
import decimal
24
import sys
35
from typing import Any, Callable, Generic, TypeVar
@@ -44,51 +46,51 @@ class Some(Generic[T]):
4446
def value(self) -> T: ...
4547

4648
class SchemaValidator:
47-
def __init__(self, schema: CoreSchema, config: 'CoreConfig | None' = None) -> None: ...
49+
def __init__(self, schema: CoreSchema, config: CoreConfig | None = None) -> None: ...
4850
@property
4951
def title(self) -> str: ...
5052
def validate_python(
5153
self,
5254
input: Any,
5355
*,
54-
strict: 'bool | None' = None,
55-
from_attributes: 'bool | None' = None,
56+
strict: bool | None = None,
57+
from_attributes: bool | None = None,
5658
context: Any = None,
57-
self_instance: 'Any | None' = None,
59+
self_instance: Any | None = None,
5860
) -> Any: ...
5961
def isinstance_python(
6062
self,
6163
input: Any,
6264
*,
63-
strict: 'bool | None' = None,
64-
from_attributes: 'bool | None' = None,
65+
strict: bool | None = None,
66+
from_attributes: bool | None = None,
6567
context: Any = None,
66-
self_instance: 'Any | None' = None,
68+
self_instance: Any | None = None,
6769
) -> bool: ...
6870
def validate_json(
6971
self,
70-
input: 'str | bytes | bytearray',
72+
input: str | bytes | bytearray,
7173
*,
72-
strict: 'bool | None' = None,
74+
strict: bool | None = None,
7375
context: Any = None,
74-
self_instance: 'Any | None' = None,
76+
self_instance: Any | None = None,
7577
) -> Any: ...
7678
def validate_assignment(
7779
self,
7880
obj: Any,
7981
field_name: str,
8082
field_value: Any,
8183
*,
82-
strict: 'bool | None' = None,
83-
from_attributes: 'bool | None' = None,
84+
strict: bool | None = None,
85+
from_attributes: bool | None = None,
8486
context: Any = None,
85-
) -> 'dict[str, Any]': ...
86-
def get_default_value(self, *, strict: 'bool | None' = None, context: Any = None) -> Some | None: ...
87+
) -> dict[str, Any]: ...
88+
def get_default_value(self, *, strict: bool | None = None, context: Any = None) -> Some | None: ...
8789

88-
IncEx: TypeAlias = 'set[int] | set[str] | dict[int, IncEx] | dict[str, IncEx] | None'
90+
IncEx: TypeAlias = set[int] | set[str] | dict[int, IncEx] | dict[str, IncEx] | None
8991

9092
class SchemaSerializer:
91-
def __init__(self, schema: CoreSchema, config: 'CoreConfig | None' = None) -> None: ...
93+
def __init__(self, schema: CoreSchema, config: CoreConfig | None = None) -> None: ...
9294
def to_python(
9395
self,
9496
value: Any,
@@ -102,7 +104,7 @@ class SchemaSerializer:
102104
exclude_none: bool = False,
103105
round_trip: bool = False,
104106
warnings: bool = True,
105-
fallback: 'Callable[[Any], Any] | None' = None,
107+
fallback: Callable[[Any], Any] | None = None,
106108
) -> Any: ...
107109
def to_json(
108110
self,
@@ -117,7 +119,7 @@ class SchemaSerializer:
117119
exclude_none: bool = False,
118120
round_trip: bool = False,
119121
warnings: bool = True,
120-
fallback: 'Callable[[Any], Any] | None' = None,
122+
fallback: Callable[[Any], Any] | None = None,
121123
) -> bytes: ...
122124

123125
def to_json(
@@ -132,7 +134,7 @@ def to_json(
132134
timedelta_mode: Literal['iso8601', 'float'] = 'iso8601',
133135
bytes_mode: Literal['utf8', 'base64'] = 'utf8',
134136
serialize_unknown: bool = False,
135-
fallback: 'Callable[[Any], Any] | None' = None,
137+
fallback: Callable[[Any], Any] | None = None,
136138
) -> bytes: ...
137139
def to_jsonable_python(
138140
value: Any,
@@ -145,64 +147,64 @@ def to_jsonable_python(
145147
timedelta_mode: Literal['iso8601', 'float'] = 'iso8601',
146148
bytes_mode: Literal['utf8', 'base64'] = 'utf8',
147149
serialize_unknown: bool = False,
148-
fallback: 'Callable[[Any], Any] | None' = None,
150+
fallback: Callable[[Any], Any] | None = None,
149151
) -> Any: ...
150152

151153
class Url(SupportsAllComparisons):
152154
def __init__(self, url: str) -> None: ...
153155
@property
154156
def scheme(self) -> str: ...
155157
@property
156-
def username(self) -> 'str | None': ...
158+
def username(self) -> str | None: ...
157159
@property
158-
def password(self) -> 'str | None': ...
160+
def password(self) -> str | None: ...
159161
@property
160-
def host(self) -> 'str | None': ...
162+
def host(self) -> str | None: ...
161163
@property
162-
def port(self) -> 'int | None': ...
164+
def port(self) -> int | None: ...
163165
@property
164-
def path(self) -> 'str | None': ...
166+
def path(self) -> str | None: ...
165167
@property
166-
def query(self) -> 'str | None': ...
168+
def query(self) -> str | None: ...
167169
@property
168-
def fragment(self) -> 'str | None': ...
169-
def unicode_host(self) -> 'str | None': ...
170-
def query_params(self) -> 'list[tuple[str, str]]': ...
170+
def fragment(self) -> str | None: ...
171+
def unicode_host(self) -> str | None: ...
172+
def query_params(self) -> list[tuple[str, str]]: ...
171173
def unicode_string(self) -> str: ...
172174
def __repr__(self) -> str: ...
173175
def __str__(self) -> str: ...
174176

175177
class MultiHostHost(TypedDict):
176-
username: 'str | None'
177-
password: 'str | None'
178-
host: 'str | None'
179-
port: 'int | None'
178+
username: str | None
179+
password: str | None
180+
host: str | None
181+
port: int | None
180182

181183
class MultiHostUrl(SupportsAllComparisons):
182184
def __init__(self, url: str) -> None: ...
183185
@property
184186
def scheme(self) -> str: ...
185187
@property
186-
def path(self) -> 'str | None': ...
188+
def path(self) -> str | None: ...
187189
@property
188-
def query(self) -> 'str | None': ...
190+
def query(self) -> str | None: ...
189191
@property
190-
def fragment(self) -> 'str | None': ...
191-
def hosts(self) -> 'list[MultiHostHost]': ...
192-
def query_params(self) -> 'list[tuple[str, str]]': ...
192+
def fragment(self) -> str | None: ...
193+
def hosts(self) -> list[MultiHostHost]: ...
194+
def query_params(self) -> list[tuple[str, str]]: ...
193195
def unicode_string(self) -> str: ...
194196
def __repr__(self) -> str: ...
195197
def __str__(self) -> str: ...
196198

197199
class SchemaError(Exception):
198200
def error_count(self) -> int: ...
199-
def errors(self) -> 'list[ErrorDetails]': ...
201+
def errors(self) -> list[ErrorDetails]: ...
200202

201203
class ValidationError(ValueError):
202204
@staticmethod
203205
def from_exception_data(
204206
title: str,
205-
errors: 'list[InitErrorDetails]',
207+
errors: list[InitErrorDetails],
206208
error_mode: Literal['python', 'json'] = 'python',
207209
hide_input: bool = False,
208210
) -> ValidationError:
@@ -215,15 +217,15 @@ class ValidationError(ValueError):
215217
@property
216218
def title(self) -> str: ...
217219
def error_count(self) -> int: ...
218-
def errors(self, *, include_url: bool = True, include_context: bool = True) -> 'list[ErrorDetails]': ...
219-
def json(self, *, indent: 'int | None' = None, include_url: bool = True, include_context: bool = True) -> str: ...
220+
def errors(self, *, include_url: bool = True, include_context: bool = True) -> list[ErrorDetails]: ...
221+
def json(self, *, indent: int | None = None, include_url: bool = True, include_context: bool = True) -> str: ...
220222

221223
class PydanticCustomError(ValueError):
222224
def __init__(
223-
self, error_type: LiteralString, message_template: LiteralString, context: 'dict[str, Any] | None' = None
225+
self, error_type: LiteralString, message_template: LiteralString, context: dict[str, Any] | None = None
224226
) -> None: ...
225227
@property
226-
def context(self) -> 'dict[str, Any] | None': ...
228+
def context(self) -> dict[str, Any] | None: ...
227229
@property
228230
def type(self) -> str: ...
229231
@property
@@ -232,10 +234,10 @@ class PydanticCustomError(ValueError):
232234

233235
class PydanticKnownError(ValueError):
234236
def __init__(
235-
self, error_type: ErrorType, context: 'dict[str, str | int | float | decimal.Decimal] | None' = None
237+
self, error_type: ErrorType, context: dict[str, str | int | float | decimal.Decimal] | None = None
236238
) -> None: ...
237239
@property
238-
def context(self) -> 'dict[str, str | int | float] | None': ...
240+
def context(self) -> dict[str, str | int | float] | None: ...
239241
@property
240242
def type(self) -> ErrorType: ...
241243
@property
@@ -249,28 +251,28 @@ class PydanticSerializationError(ValueError):
249251
def __init__(self, message: str) -> None: ...
250252

251253
class PydanticSerializationUnexpectedValue(ValueError):
252-
def __init__(self, message: 'str | None' = None) -> None: ...
254+
def __init__(self, message: str | None = None) -> None: ...
253255

254256
class ErrorTypeInfo(TypedDict):
255257
type: ErrorType
256258
message_template_python: str
257259
example_message_python: str
258260
message_template_json: NotRequired[str]
259261
example_message_json: NotRequired[str]
260-
example_context: 'dict[str, str | int | float] | None'
262+
example_context: dict[str, str | int | float] | None
261263

262264
class ArgsKwargs:
263-
def __init__(self, args: 'tuple[Any, ...]', kwargs: 'dict[str, Any] | None' = None) -> None: ...
265+
def __init__(self, args: tuple[Any, ...], kwargs: dict[str, Any] | None = None) -> None: ...
264266
@property
265-
def args(self) -> 'tuple[Any, ...]': ...
267+
def args(self) -> tuple[Any, ...]: ...
266268
@property
267-
def kwargs(self) -> 'dict[str, Any] | None': ...
269+
def kwargs(self) -> dict[str, Any] | None: ...
268270

269271
class PydanticUndefinedType: ...
270272

271273
PydanticUndefined: PydanticUndefinedType
272274

273-
def list_all_errors() -> 'list[ErrorTypeInfo]':
275+
def list_all_errors() -> list[ErrorTypeInfo]:
274276
"""
275277
Get information about all built-in errors.
276278
"""

0 commit comments

Comments
 (0)