On this page
  1. typing.dataclass_transform
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

typing.dataclass_transform

Prev: typing.Counter | Up: typing | Next: typing.DefaultDict
Rel: typing.AbstractSet, typing.Annotated, typing.Any, typing.assert_never
Ref: docs.python.org — typing.dataclass_transform
Tags: #public #python3 #stdlib #typing


Import

import typing
from typing import dataclass_transform

Signature & Overview

typing.dataclass_transform(*, eq_default: bool = True, order_default: bool = False, kw_only_default: bool = False, frozen_default: bool = False, field_specifiers: tuple[type[typing.Any] | typing.Callable[..., typing.Any], ...] = (), **kwargs: Any) -> <class '_IdentityCallable'>

Decorator to mark an object as providing dataclass-like behavior.

Usage

from typing import dataclass_transform

@dataclass_transform(kw_only_default=True)
def my_model(cls):
    return cls

assert callable(my_model)

Gotchas

REPL Inspect

from typing import dataclass_transform
help(dataclass_transform)

Linked from

Related notes