Update __dataclass_params__ to track actual changes made by decorator
@ericvsmith arbeitet bereits daran.
Seit 23.11.2022.
- Vorherrschende Sprache
- Python
- Sterne
- 77.2k
- Forks
- 36k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
Several of the options available via the dataclass decorator, such as repr, hash, and eq, are ignored if the corresponding methods are already in the class being decorated; however, they still have their default value of True. This makes it difficult, if not impossible, to discern whether a dataclass' special method was given by dataclass or if the user wrote it.
As an example of the introspection concern, Enum uses __dataclass_params__.repr to decide if it should use a dataclass-specific repr, or use the dataclass' repr. Without this enhancement, the user has to both specify @dataclass(repr=False) and include their new __repr__ method, instead of just including the new __repr__ and having dataclass automatically set __dataclass_params__.repr to False.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Bewertung
Dieses Issue wurde noch nicht bewertet.