mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-08-01 13:40:23 +08:00
More accurate dataclasses.dataclass overloads (#14095)
This commit is contained in:
+49
-4
@@ -71,14 +71,28 @@ def asdict(obj: DataclassInstance, *, dict_factory: Callable[[list[tuple[str, An
|
||||
def astuple(obj: DataclassInstance) -> tuple[Any, ...]: ...
|
||||
@overload
|
||||
def astuple(obj: DataclassInstance, *, tuple_factory: Callable[[list[Any]], _T]) -> _T: ...
|
||||
@overload
|
||||
def dataclass(cls: None, /) -> Callable[[type[_T]], type[_T]]: ...
|
||||
@overload
|
||||
def dataclass(cls: type[_T], /) -> type[_T]: ...
|
||||
|
||||
if sys.version_info >= (3, 11):
|
||||
@overload
|
||||
def dataclass(
|
||||
cls: type[_T],
|
||||
/,
|
||||
*,
|
||||
init: bool = True,
|
||||
repr: bool = True,
|
||||
eq: bool = True,
|
||||
order: bool = False,
|
||||
unsafe_hash: bool = False,
|
||||
frozen: bool = False,
|
||||
match_args: bool = True,
|
||||
kw_only: bool = False,
|
||||
slots: bool = False,
|
||||
weakref_slot: bool = False,
|
||||
) -> type[_T]: ...
|
||||
@overload
|
||||
def dataclass(
|
||||
cls: None = None,
|
||||
/,
|
||||
*,
|
||||
init: bool = True,
|
||||
repr: bool = True,
|
||||
@@ -95,6 +109,23 @@ if sys.version_info >= (3, 11):
|
||||
elif sys.version_info >= (3, 10):
|
||||
@overload
|
||||
def dataclass(
|
||||
cls: type[_T],
|
||||
/,
|
||||
*,
|
||||
init: bool = True,
|
||||
repr: bool = True,
|
||||
eq: bool = True,
|
||||
order: bool = False,
|
||||
unsafe_hash: bool = False,
|
||||
frozen: bool = False,
|
||||
match_args: bool = True,
|
||||
kw_only: bool = False,
|
||||
slots: bool = False,
|
||||
) -> type[_T]: ...
|
||||
@overload
|
||||
def dataclass(
|
||||
cls: None = None,
|
||||
/,
|
||||
*,
|
||||
init: bool = True,
|
||||
repr: bool = True,
|
||||
@@ -110,6 +141,20 @@ elif sys.version_info >= (3, 10):
|
||||
else:
|
||||
@overload
|
||||
def dataclass(
|
||||
cls: type[_T],
|
||||
/,
|
||||
*,
|
||||
init: bool = True,
|
||||
repr: bool = True,
|
||||
eq: bool = True,
|
||||
order: bool = False,
|
||||
unsafe_hash: bool = False,
|
||||
frozen: bool = False,
|
||||
) -> type[_T]: ...
|
||||
@overload
|
||||
def dataclass(
|
||||
cls: None = None,
|
||||
/,
|
||||
*,
|
||||
init: bool = True,
|
||||
repr: bool = True,
|
||||
|
||||
Reference in New Issue
Block a user