Skip to content

Commit

Permalink
Use new typing syntax for _pydantic_core.pyi (pydantic#1217)
Browse files Browse the repository at this point in the history
Co-authored-by: David Hewitt <mail@davidhewitt.dev>
  • Loading branch information
Viicos and davidhewitt authored Mar 13, 2024
1 parent 10095b5 commit 9efbc16
Showing 1 changed file with 20 additions and 32 deletions.
52 changes: 20 additions & 32 deletions python/pydantic_core/_pydantic_core.pyi
Original file line number Diff line number Diff line change
@@ -1,24 +1,12 @@
from __future__ import annotations

import datetime
import sys
from typing import Any, Callable, Generic, Optional, Type, TypeVar
from typing import Any, Callable, Generic, Literal, TypeVar, final

from _typeshed import SupportsAllComparisons
from typing_extensions import LiteralString, Self, TypeAlias

from pydantic_core import ErrorDetails, ErrorTypeInfo, InitErrorDetails, MultiHostHost
from pydantic_core.core_schema import CoreConfig, CoreSchema, ErrorType

if sys.version_info < (3, 8):
from typing_extensions import final
else:
from typing import final

if sys.version_info < (3, 11):
from typing_extensions import Literal, LiteralString, Self, TypeAlias
else:
from typing import Literal, LiteralString, Self, TypeAlias

from _typeshed import SupportsAllComparisons

__all__ = [
'__version__',
'build_profile',
Expand Down Expand Up @@ -73,7 +61,7 @@ class Some(Generic[_T]):
Returns the value wrapped by `Some`.
"""
@classmethod
def __class_getitem__(cls, item: Any, /) -> Type[Self]: ...
def __class_getitem__(cls, item: Any, /) -> type[Self]: ...

@final
class SchemaValidator:
Expand Down Expand Up @@ -569,13 +557,13 @@ class Url(SupportsAllComparisons):
cls,
*,
scheme: str,
username: Optional[str] = None,
password: Optional[str] = None,
username: str | None = None,
password: str | None = None,
host: str,
port: Optional[int] = None,
path: Optional[str] = None,
query: Optional[str] = None,
fragment: Optional[str] = None,
port: int | None = None,
path: str | None = None,
query: str | None = None,
fragment: str | None = None,
) -> Self:
"""
Build a new `Url` instance from its component parts.
Expand Down Expand Up @@ -683,14 +671,14 @@ class MultiHostUrl(SupportsAllComparisons):
cls,
*,
scheme: str,
hosts: Optional[list[MultiHostHost]] = None,
username: Optional[str] = None,
password: Optional[str] = None,
host: Optional[str] = None,
port: Optional[int] = None,
path: Optional[str] = None,
query: Optional[str] = None,
fragment: Optional[str] = None,
hosts: list[MultiHostHost] | None = None,
username: str | None = None,
password: str | None = None,
host: str | None = None,
port: int | None = None,
path: str | None = None,
query: str | None = None,
fragment: str | None = None,
) -> Self:
"""
Build a new `MultiHostUrl` instance from its component parts.
Expand Down Expand Up @@ -883,7 +871,7 @@ class TzInfo(datetime.tzinfo):
def utcoffset(self, _dt: datetime.datetime | None) -> datetime.timedelta: ...
def dst(self, _dt: datetime.datetime | None) -> datetime.timedelta: ...
def fromutc(self, dt: datetime.datetime) -> datetime.datetime: ...
def __deepcopy__(self, _memo: dict[Any, Any]) -> 'TzInfo': ...
def __deepcopy__(self, _memo: dict[Any, Any]) -> TzInfo: ...

def validate_core_schema(schema: CoreSchema, *, strict: bool | None = None) -> CoreSchema:
"""Validate a CoreSchema
Expand Down

0 comments on commit 9efbc16

Please sign in to comment.