python / python/cpython

Prevent `@dataclass` from being called twice on the same class

Open
#92,231 7 comments 0 reactions 1 assignee View on GitHub

@ericvsmith is already working on this.

Since May 3, 2022.

3.11 stdlib topic-dataclasses type-feature
Dominant language
Python
Stars
77.2k
Forks
36k
PR merge metrics
PR metrics pending

Description

Currently it's possible to do this:

@dataclass(repr=False)
@dataclass(repr=True)
class C:
    pass

This is confusing at best, and will produce unexpected classes at worst.

With this change, that will become an error.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.