Skip to content

Use from __future__ import annotations instead of string type hints in python/pydantic_core/_pydantic_core.pyi #710

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 49 additions & 47 deletions python/pydantic_core/_pydantic_core.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import decimal
import sys
from typing import Any, Callable, Generic, Type, TypeVar
Expand Down Expand Up @@ -55,52 +57,52 @@ class Some(Generic[_T]):

@final
class SchemaValidator:
def __init__(self, schema: CoreSchema, config: 'CoreConfig | None' = None) -> None: ...
def __init__(self, schema: CoreSchema, config: CoreConfig | None = None) -> None: ...
@property
def title(self) -> str: ...
def validate_python(
self,
input: Any,
*,
strict: 'bool | None' = None,
from_attributes: 'bool | None' = None,
strict: bool | None = None,
from_attributes: bool | None = None,
context: Any = None,
self_instance: 'Any | None' = None,
self_instance: Any | None = None,
) -> Any: ...
def isinstance_python(
self,
input: Any,
*,
strict: 'bool | None' = None,
from_attributes: 'bool | None' = None,
strict: bool | None = None,
from_attributes: bool | None = None,
context: Any = None,
self_instance: 'Any | None' = None,
self_instance: Any | None = None,
) -> bool: ...
def validate_json(
self,
input: 'str | bytes | bytearray',
input: str | bytes | bytearray,
*,
strict: 'bool | None' = None,
strict: bool | None = None,
context: Any = None,
self_instance: 'Any | None' = None,
self_instance: Any | None = None,
) -> Any: ...
def validate_assignment(
self,
obj: Any,
field_name: str,
field_value: Any,
*,
strict: 'bool | None' = None,
from_attributes: 'bool | None' = None,
strict: bool | None = None,
from_attributes: bool | None = None,
context: Any = None,
) -> 'dict[str, Any]': ...
def get_default_value(self, *, strict: 'bool | None' = None, context: Any = None) -> Some | None: ...
) -> dict[str, Any]: ...
def get_default_value(self, *, strict: bool | None = None, context: Any = None) -> Some | None: ...

_IncEx: TypeAlias = 'set[int] | set[str] | dict[int, _IncEx] | dict[str, _IncEx] | None'
_IncEx: TypeAlias = set[int] | set[str] | dict[int, _IncEx] | dict[str, _IncEx] | None

@final
class SchemaSerializer:
def __init__(self, schema: CoreSchema, config: 'CoreConfig | None' = None) -> None: ...
def __init__(self, schema: CoreSchema, config: CoreConfig | None = None) -> None: ...
def to_python(
self,
value: Any,
Expand All @@ -114,7 +116,7 @@ class SchemaSerializer:
exclude_none: bool = False,
round_trip: bool = False,
warnings: bool = True,
fallback: 'Callable[[Any], Any] | None' = None,
fallback: Callable[[Any], Any] | None = None,
) -> Any: ...
def to_json(
self,
Expand All @@ -129,7 +131,7 @@ class SchemaSerializer:
exclude_none: bool = False,
round_trip: bool = False,
warnings: bool = True,
fallback: 'Callable[[Any], Any] | None' = None,
fallback: Callable[[Any], Any] | None = None,
) -> bytes: ...

def to_json(
Expand All @@ -144,7 +146,7 @@ def to_json(
timedelta_mode: Literal['iso8601', 'float'] = 'iso8601',
bytes_mode: Literal['utf8', 'base64'] = 'utf8',
serialize_unknown: bool = False,
fallback: 'Callable[[Any], Any] | None' = None,
fallback: Callable[[Any], Any] | None = None,
) -> bytes: ...
def to_jsonable_python(
value: Any,
Expand All @@ -157,29 +159,29 @@ def to_jsonable_python(
timedelta_mode: Literal['iso8601', 'float'] = 'iso8601',
bytes_mode: Literal['utf8', 'base64'] = 'utf8',
serialize_unknown: bool = False,
fallback: 'Callable[[Any], Any] | None' = None,
fallback: Callable[[Any], Any] | None = None,
) -> Any: ...

class Url(SupportsAllComparisons):
def __init__(self, url: str) -> None: ...
@property
def scheme(self) -> str: ...
@property
def username(self) -> 'str | None': ...
def username(self) -> str | None: ...
@property
def password(self) -> 'str | None': ...
def password(self) -> str | None: ...
@property
def host(self) -> 'str | None': ...
def host(self) -> str | None: ...
@property
def port(self) -> 'int | None': ...
def port(self) -> int | None: ...
@property
def path(self) -> 'str | None': ...
def path(self) -> str | None: ...
@property
def query(self) -> 'str | None': ...
def query(self) -> str | None: ...
@property
def fragment(self) -> 'str | None': ...
def unicode_host(self) -> 'str | None': ...
def query_params(self) -> 'list[tuple[str, str]]': ...
def fragment(self) -> str | None: ...
def unicode_host(self) -> str | None: ...
def query_params(self) -> list[tuple[str, str]]: ...
def unicode_string(self) -> str: ...
def __repr__(self) -> str: ...
def __str__(self) -> str: ...
Expand All @@ -190,13 +192,13 @@ class MultiHostUrl(SupportsAllComparisons):
@property
def scheme(self) -> str: ...
@property
def path(self) -> 'str | None': ...
def path(self) -> str | None: ...
@property
def query(self) -> 'str | None': ...
def query(self) -> str | None: ...
@property
def fragment(self) -> 'str | None': ...
def hosts(self) -> 'list[MultiHostHost]': ...
def query_params(self) -> 'list[tuple[str, str]]': ...
def fragment(self) -> str | None: ...
def hosts(self) -> list[MultiHostHost]: ...
def query_params(self) -> list[tuple[str, str]]: ...
def unicode_string(self) -> str: ...
def __repr__(self) -> str: ...
def __str__(self) -> str: ...
Expand All @@ -205,14 +207,14 @@ class MultiHostUrl(SupportsAllComparisons):
@final
class SchemaError(Exception):
def error_count(self) -> int: ...
def errors(self) -> 'list[ErrorDetails]': ...
def errors(self) -> list[ErrorDetails]: ...

@final
class ValidationError(ValueError):
@staticmethod
def from_exception_data(
title: str,
line_errors: 'list[InitErrorDetails]',
line_errors: list[InitErrorDetails],
error_mode: Literal['python', 'json'] = 'python',
hide_input: bool = False,
) -> ValidationError:
Expand All @@ -225,16 +227,16 @@ class ValidationError(ValueError):
@property
def title(self) -> str: ...
def error_count(self) -> int: ...
def errors(self, *, include_url: bool = True, include_context: bool = True) -> 'list[ErrorDetails]': ...
def json(self, *, indent: 'int | None' = None, include_url: bool = True, include_context: bool = True) -> str: ...
def errors(self, *, include_url: bool = True, include_context: bool = True) -> list[ErrorDetails]: ...
def json(self, *, indent: int | None = None, include_url: bool = True, include_context: bool = True) -> str: ...

@final
class PydanticCustomError(ValueError):
def __init__(
self, error_type: LiteralString, message_template: LiteralString, context: 'dict[str, Any] | None' = None
self, error_type: LiteralString, message_template: LiteralString, context: dict[str, Any] | None = None
) -> None: ...
@property
def context(self) -> 'dict[str, Any] | None': ...
def context(self) -> dict[str, Any] | None: ...
@property
def type(self) -> str: ...
@property
Expand All @@ -244,10 +246,10 @@ class PydanticCustomError(ValueError):
@final
class PydanticKnownError(ValueError):
def __init__(
self, error_type: ErrorType, context: 'dict[str, str | int | float | decimal.Decimal] | None' = None
self, error_type: ErrorType, context: dict[str, str | int | float | decimal.Decimal] | None = None
) -> None: ...
@property
def context(self) -> 'dict[str, str | int | float] | None': ...
def context(self) -> dict[str, str | int | float] | None: ...
@property
def type(self) -> ErrorType: ...
@property
Expand All @@ -264,15 +266,15 @@ class PydanticSerializationError(ValueError):

@final
class PydanticSerializationUnexpectedValue(ValueError):
def __init__(self, message: 'str | None' = None) -> None: ...
def __init__(self, message: str | None = None) -> None: ...

@final
class ArgsKwargs:
def __init__(self, args: 'tuple[Any, ...]', kwargs: 'dict[str, Any] | None' = None) -> None: ...
def __init__(self, args: tuple[Any, ...], kwargs: dict[str, Any] | None = None) -> None: ...
@property
def args(self) -> 'tuple[Any, ...]': ...
def args(self) -> tuple[Any, ...]: ...
@property
def kwargs(self) -> 'dict[str, Any] | None': ...
def kwargs(self) -> dict[str, Any] | None: ...

@final
class PydanticUndefinedType:
Expand All @@ -281,7 +283,7 @@ class PydanticUndefinedType:

PydanticUndefined: PydanticUndefinedType

def list_all_errors() -> 'list[ErrorTypeInfo]':
def list_all_errors() -> list[ErrorTypeInfo]:
"""
Get information about all built-in errors.
"""