python / python/cpython

Update __dataclass_params__ to track actual changes made by decorator

Đang mở
#99,713 3 bình luận 0 reaction 1 người được giao Xem trên GitHub

@ericvsmith đang làm issue này rồi.

Từ ngày 23/11/2022.

stdlib topic-dataclasses type-feature
Ngôn ngữ chính
Python
Star
77.2k
Fork
36k
Chỉ số merge pull request
Chỉ số pull request đang chờ

Mô tả

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.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.