Skip to content

Commit 081cf31

Browse files
authored
Use from __future__ import annotations instead of string type hints in python/pydantic_core/_pydantic_core.pyi (#710)
1 parent 54daab7 commit 081cf31

File tree

1 file changed

+49
-47
lines changed

1 file changed

+49
-47
lines changed

python/pydantic_core/_pydantic_core.pyi

Lines changed: 49 additions & 47 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, Type, TypeVar
@@ -55,52 +57,52 @@ class Some(Generic[_T]):
5557

5658
@final
5759
class SchemaValidator:
58-
def __init__(self, schema: CoreSchema, config: 'CoreConfig | None' = None) -> None: ...
60+
def __init__(self, schema: CoreSchema, config: CoreConfig | None = None) -> None: ...
5961
@property
6062
def title(self) -> str: ...
6163
def validate_python(
6264
self,
6365
input: Any,
6466
*,
65-
strict: 'bool | None' = None,
66-
from_attributes: 'bool | None' = None,
67+
strict: bool | None = None,
68+
from_attributes: bool | None = None,
6769
context: Any = None,
68-
self_instance: 'Any | None' = None,
70+
self_instance: Any | None = None,
6971
) -> Any: ...
7072
def isinstance_python(
7173
self,
7274
input: Any,
7375
*,
74-
strict: 'bool | None' = None,
75-
from_attributes: 'bool | None' = None,
76+
strict: bool | None = None,
77+
from_attributes: bool | None = None,
7678
context: Any = None,
77-
self_instance: 'Any | None' = None,
79+
self_instance: Any | None = None,
7880
) -> bool: ...
7981
def validate_json(
8082
self,
81-
input: 'str | bytes | bytearray',
83+
input: str | bytes | bytearray,
8284
*,
83-
strict: 'bool | None' = None,
85+
strict: bool | None = None,
8486
context: Any = None,
85-
self_instance: 'Any | None' = None,
87+
self_instance: Any | None = None,
8688
) -> Any: ...
8789
def validate_assignment(
8890
self,
8991
obj: Any,
9092
field_name: str,
9193
field_value: Any,
9294
*,
93-
strict: 'bool | None' = None,
94-
from_attributes: 'bool | None' = None,
95+
strict: bool | None = None,
96+
from_attributes: bool | None = None,
9597
context: Any = None,
96-
) -> 'dict[str, Any]': ...
97-
def get_default_value(self, *, strict: 'bool | None' = None, context: Any = None) -> Some | None: ...
98+
) -> dict[str, Any]: ...
99+
def get_default_value(self, *, strict: bool | None = None, context: Any = None) -> Some | None: ...
98100

99-
_IncEx: TypeAlias = 'set[int] | set[str] | dict[int, _IncEx] | dict[str, _IncEx] | None'
101+
_IncEx: TypeAlias = set[int] | set[str] | dict[int, _IncEx] | dict[str, _IncEx] | None
100102

101103
@final
102104
class SchemaSerializer:
103-
def __init__(self, schema: CoreSchema, config: 'CoreConfig | None' = None) -> None: ...
105+
def __init__(self, schema: CoreSchema, config: CoreConfig | None = None) -> None: ...
104106
def to_python(
105107
self,
106108
value: Any,
@@ -114,7 +116,7 @@ class SchemaSerializer:
114116
exclude_none: bool = False,
115117
round_trip: bool = False,
116118
warnings: bool = True,
117-
fallback: 'Callable[[Any], Any] | None' = None,
119+
fallback: Callable[[Any], Any] | None = None,
118120
) -> Any: ...
119121
def to_json(
120122
self,
@@ -129,7 +131,7 @@ class SchemaSerializer:
129131
exclude_none: bool = False,
130132
round_trip: bool = False,
131133
warnings: bool = True,
132-
fallback: 'Callable[[Any], Any] | None' = None,
134+
fallback: Callable[[Any], Any] | None = None,
133135
) -> bytes: ...
134136

135137
def to_json(
@@ -144,7 +146,7 @@ def to_json(
144146
timedelta_mode: Literal['iso8601', 'float'] = 'iso8601',
145147
bytes_mode: Literal['utf8', 'base64'] = 'utf8',
146148
serialize_unknown: bool = False,
147-
fallback: 'Callable[[Any], Any] | None' = None,
149+
fallback: Callable[[Any], Any] | None = None,
148150
) -> bytes: ...
149151
def to_jsonable_python(
150152
value: Any,
@@ -157,29 +159,29 @@ def to_jsonable_python(
157159
timedelta_mode: Literal['iso8601', 'float'] = 'iso8601',
158160
bytes_mode: Literal['utf8', 'base64'] = 'utf8',
159161
serialize_unknown: bool = False,
160-
fallback: 'Callable[[Any], Any] | None' = None,
162+
fallback: Callable[[Any], Any] | None = None,
161163
) -> Any: ...
162164

163165
class Url(SupportsAllComparisons):
164166
def __init__(self, url: str) -> None: ...
165167
@property
166168
def scheme(self) -> str: ...
167169
@property
168-
def username(self) -> 'str | None': ...
170+
def username(self) -> str | None: ...
169171
@property
170-
def password(self) -> 'str | None': ...
172+
def password(self) -> str | None: ...
171173
@property
172-
def host(self) -> 'str | None': ...
174+
def host(self) -> str | None: ...
173175
@property
174-
def port(self) -> 'int | None': ...
176+
def port(self) -> int | None: ...
175177
@property
176-
def path(self) -> 'str | None': ...
178+
def path(self) -> str | None: ...
177179
@property
178-
def query(self) -> 'str | None': ...
180+
def query(self) -> str | None: ...
179181
@property
180-
def fragment(self) -> 'str | None': ...
181-
def unicode_host(self) -> 'str | None': ...
182-
def query_params(self) -> 'list[tuple[str, str]]': ...
182+
def fragment(self) -> str | None: ...
183+
def unicode_host(self) -> str | None: ...
184+
def query_params(self) -> list[tuple[str, str]]: ...
183185
def unicode_string(self) -> str: ...
184186
def __repr__(self) -> str: ...
185187
def __str__(self) -> str: ...
@@ -190,13 +192,13 @@ class MultiHostUrl(SupportsAllComparisons):
190192
@property
191193
def scheme(self) -> str: ...
192194
@property
193-
def path(self) -> 'str | None': ...
195+
def path(self) -> str | None: ...
194196
@property
195-
def query(self) -> 'str | None': ...
197+
def query(self) -> str | None: ...
196198
@property
197-
def fragment(self) -> 'str | None': ...
198-
def hosts(self) -> 'list[MultiHostHost]': ...
199-
def query_params(self) -> 'list[tuple[str, str]]': ...
199+
def fragment(self) -> str | None: ...
200+
def hosts(self) -> list[MultiHostHost]: ...
201+
def query_params(self) -> list[tuple[str, str]]: ...
200202
def unicode_string(self) -> str: ...
201203
def __repr__(self) -> str: ...
202204
def __str__(self) -> str: ...
@@ -205,14 +207,14 @@ class MultiHostUrl(SupportsAllComparisons):
205207
@final
206208
class SchemaError(Exception):
207209
def error_count(self) -> int: ...
208-
def errors(self) -> 'list[ErrorDetails]': ...
210+
def errors(self) -> list[ErrorDetails]: ...
209211

210212
@final
211213
class ValidationError(ValueError):
212214
@staticmethod
213215
def from_exception_data(
214216
title: str,
215-
line_errors: 'list[InitErrorDetails]',
217+
line_errors: list[InitErrorDetails],
216218
error_mode: Literal['python', 'json'] = 'python',
217219
hide_input: bool = False,
218220
) -> ValidationError:
@@ -225,16 +227,16 @@ class ValidationError(ValueError):
225227
@property
226228
def title(self) -> str: ...
227229
def error_count(self) -> int: ...
228-
def errors(self, *, include_url: bool = True, include_context: bool = True) -> 'list[ErrorDetails]': ...
229-
def json(self, *, indent: 'int | None' = None, include_url: bool = True, include_context: bool = True) -> str: ...
230+
def errors(self, *, include_url: bool = True, include_context: bool = True) -> list[ErrorDetails]: ...
231+
def json(self, *, indent: int | None = None, include_url: bool = True, include_context: bool = True) -> str: ...
230232

231233
@final
232234
class PydanticCustomError(ValueError):
233235
def __init__(
234-
self, error_type: LiteralString, message_template: LiteralString, context: 'dict[str, Any] | None' = None
236+
self, error_type: LiteralString, message_template: LiteralString, context: dict[str, Any] | None = None
235237
) -> None: ...
236238
@property
237-
def context(self) -> 'dict[str, Any] | None': ...
239+
def context(self) -> dict[str, Any] | None: ...
238240
@property
239241
def type(self) -> str: ...
240242
@property
@@ -244,10 +246,10 @@ class PydanticCustomError(ValueError):
244246
@final
245247
class PydanticKnownError(ValueError):
246248
def __init__(
247-
self, error_type: ErrorType, context: 'dict[str, str | int | float | decimal.Decimal] | None' = None
249+
self, error_type: ErrorType, context: dict[str, str | int | float | decimal.Decimal] | None = None
248250
) -> None: ...
249251
@property
250-
def context(self) -> 'dict[str, str | int | float] | None': ...
252+
def context(self) -> dict[str, str | int | float] | None: ...
251253
@property
252254
def type(self) -> ErrorType: ...
253255
@property
@@ -264,15 +266,15 @@ class PydanticSerializationError(ValueError):
264266

265267
@final
266268
class PydanticSerializationUnexpectedValue(ValueError):
267-
def __init__(self, message: 'str | None' = None) -> None: ...
269+
def __init__(self, message: str | None = None) -> None: ...
268270

269271
@final
270272
class ArgsKwargs:
271-
def __init__(self, args: 'tuple[Any, ...]', kwargs: 'dict[str, Any] | None' = None) -> None: ...
273+
def __init__(self, args: tuple[Any, ...], kwargs: dict[str, Any] | None = None) -> None: ...
272274
@property
273-
def args(self) -> 'tuple[Any, ...]': ...
275+
def args(self) -> tuple[Any, ...]: ...
274276
@property
275-
def kwargs(self) -> 'dict[str, Any] | None': ...
277+
def kwargs(self) -> dict[str, Any] | None: ...
276278

277279
@final
278280
class PydanticUndefinedType:
@@ -281,7 +283,7 @@ class PydanticUndefinedType:
281283

282284
PydanticUndefined: PydanticUndefinedType
283285

284-
def list_all_errors() -> 'list[ErrorTypeInfo]':
286+
def list_all_errors() -> list[ErrorTypeInfo]:
285287
"""
286288
Get information about all built-in errors.
287289
"""

0 commit comments

Comments
 (0)