Add decorator to mark class as concrete / instantiable
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Python
- Star
- 1.8k
- Fork
- 302
- Merge trung bình
- 23 giờ
- Pull request đã merge (30 ngày)
- 8
Mô tả
We have the @final decorator to mark a class as final, so that it cannot be subclassed. Typecheckers can then cue off of this to raise an error when there are unimplemented abstract methods (e.g. the Ty abstract-method-in-final-class rule).
Similarly, Pyright and Ty can flag errors when other code instantiates a class that has abstract methods.
However, I would find it very useful to be able to mark a class as concrete: it isn't final (someone might subclass it), but it is intended to be instantiable. This would allow the type checker to raise abstract method errors at the point of class definition, rather than elsewhere in the code where the class is instantiated. For classes that are instantiated directly, the error location isn't a huge problem; for classes that are primarily instantiated indirectly, however, it there is no guarantee that the code will include a direct instantiation of the class to raise an error.
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu bằng việc xem xét đề xuất cùng với decorator @final hiện có và hành vi của các phương thức trừu tượng được mô tả cho Pyright và Ty. Xác định ngữ nghĩa kiểm tra kiểu dự kiến của decorator lớp cụ thể và xác nhận rằng lỗi được báo cáo tại thời điểm định nghĩa lớp đối với các lớp có phương thức trừu tượng, mà không làm cho lớp trở thành final.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- python
- Lĩnh vực
- devtools
- Loại issue
- Tính năng
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100