Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Better type for dataclass_transform
  • Loading branch information
JelleZijlstra committed May 17, 2023
commit 754dda03878798947b615d60fae57b6deb86799e
9 changes: 7 additions & 2 deletions Lib/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -3202,15 +3202,20 @@ def reveal_type[T](obj: T, /) -> T:
return obj


def dataclass_transform[T](
class _IdentityCallable(Protocol):
def __call__[T](self, arg: T, /) -> T:
...


def dataclass_transform(
*,
eq_default: bool = True,
order_default: bool = False,
kw_only_default: bool = False,
frozen_default: bool = False,
field_specifiers: tuple[type[Any] | Callable[..., Any], ...] = (),
**kwargs: Any,
) -> Callable[[T], T]:
) -> _IdentityCallable:
"""Decorator that marks a function, class, or metaclass as providing
dataclass-like behavior.

Expand Down