Skip to content

Support for attrs #2480

@9ao9ai9ar

Description

@9ao9ai9ar

attrs is the inspiration for and the continuously improved version of the Python dataclasses with many additional features and almost 4 hundred million downloads last month, according to ClickPy. I would like to request that two new output model types be added:

  1. attrs.define for generating attrs classes using its new API, and
  2. attr.dataclass as a drop-in replacement of dataclasses.dataclass for better interop with attrs.

The latter output type should be easy to implement, as currently I only need to monkey patch one line in the generated file: change from dataclasses import dataclass to from attr import dataclass. But this tiny change allows, for example, attrs.fields(C) to list the attrs attributes of the decorated class C, and once #2437 lands, more customization options would become available for free.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions