Python dataclass decorator

Python 3.7+

This is a handy decorator is you make a class that should just hold some data. When you use the @dataclass decorator you get some basic functions for free, such as __init__, __repr__, __eq__, etc.

Example:

from dataclasses import dataclass

@dataclass
class Point:
    x: float
    y: float

point = Point(1.0, 2.0)
point  # Point(x=1.0, y=2.0)

The package pydantic offers richer data classes with validation schemes that integrate with various tools, such as pandera or fastapi.