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
Update to pyright==1.1.345
#8453
Changes from 6 commits
220cdc2
64c6082
66a320e
dec5b1f
9120cfa
84c1e75
7502d29
572e457
52c1ba6
bc9fe04
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
|
||
import sys | ||
from dataclasses import is_dataclass | ||
from typing import TYPE_CHECKING, Any, Dict, Generic, Iterable, Set, TypeVar, Union, cast, overload | ||
from typing import TYPE_CHECKING, Any, Dict, Generic, Iterable, Set, TypeVar, Union, cast | ||
|
||
from pydantic_core import CoreSchema, SchemaSerializer, SchemaValidator, Some | ||
from typing_extensions import Literal, get_args, is_typeddict | ||
|
@@ -24,6 +24,7 @@ | |
|
||
T = TypeVar('T') | ||
|
||
|
||
if TYPE_CHECKING: | ||
# should be `set[int] | set[str] | dict[int, IncEx] | dict[str, IncEx] | None`, but mypy can't cope | ||
IncEx = Union[Set[int], Set[str], Dict[int, Any], Dict[str, Any]] | ||
|
@@ -120,40 +121,13 @@ class TypeAdapter(Generic[T]): | |
serializer: The schema serializer for the type. | ||
""" | ||
|
||
if TYPE_CHECKING: | ||
|
||
@overload | ||
def __new__(cls, __type: type[T], *, config: ConfigDict | None = ...) -> TypeAdapter[T]: | ||
... | ||
Comment on lines
-125
to
-127
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't we basically loose all typing for |
||
|
||
# this overload is for non-type things like Union[int, str] | ||
# Pyright currently handles this "correctly", but MyPy understands this as TypeAdapter[object] | ||
# so an explicit type cast is needed | ||
@overload | ||
def __new__(cls, __type: T, *, config: ConfigDict | None = ...) -> TypeAdapter[T]: | ||
... | ||
|
||
def __new__(cls, __type: Any, *, config: ConfigDict | None = None) -> TypeAdapter[T]: | ||
"""A class representing the type adapter.""" | ||
raise NotImplementedError | ||
|
||
@overload | ||
def __init__( | ||
self, type: type[T], *, config: ConfigDict | None = None, _parent_depth: int = 2, module: str | None = None | ||
) -> None: | ||
... | ||
|
||
# this overload is for non-type things like Union[int, str] | ||
# Pyright currently handles this "correctly", but MyPy understands this as TypeAdapter[object] | ||
# so an explicit type cast is needed | ||
@overload | ||
def __init__( | ||
self, type: T, *, config: ConfigDict | None = None, _parent_depth: int = 2, module: str | None = None | ||
) -> None: | ||
... | ||
|
||
def __init__( | ||
self, type: Any, *, config: ConfigDict | None = None, _parent_depth: int = 2, module: str | None = None | ||
self, | ||
type: type[T], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this work now? What about passing in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Following up, this doesn't work: from pydantic import TypeAdapter
from typing import Union
adapter: TypeAdapter[Union[int, str]] = TypeAdapter(Union[int, str]) -->
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there any downside of leaving the above overloads within the |
||
*, | ||
config: ConfigDict | None = None, | ||
_parent_depth: int = 2, | ||
module: str | None = None, | ||
) -> None: | ||
"""Initializes the TypeAdapter object. | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the problem here / what error is raised?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Method "model_construct" overrides class "BaseModel" in an incompatible manner
, due to the fact thatreportIncompatibleMethodOverride
was recently reported by default to be compliant with the typing spec.