[docutils] Allow directive subclasses to type their options
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Python
- Star
- 5.1k
- Fork
- 2.1k
- Merge trung bình
- 1 ngày 19 giờ
- Pull request đã merge (30 ngày)
- 82
Mô tả
Directive.options is annotated as dict[str, Incomplete]. Although each
directive subclass knows the keys and converted value types defined by its
option_spec, it cannot express that shape, forcing downstream code to
propagate Any or add casts and suppressions. One example is
https://github.com/adamtheturtle/sphinx-literalizer/pull/516.
Could Directive accept an option-mapping type parameter, defaulting to the
current incomplete mapping for compatibility? This would let subclasses use a
TypedDict for their converted options. Other designs that allow subclasses to
specialize options would also solve the problem.
Hướng dẫn đóng góp
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 từ điểm vào Directive của docutils, tập trung vào mối quan hệ giữa chú thích của options và option_spec. Tìm hiểu cách một tham số ánh xạ tùy chọn generic có thể giữ nguyên ánh xạ chưa hoàn chỉnh hiện tại theo mặc định, đồng thời cho phép các lớp con sử dụng TypedDict; được xem là hoàn thành khi mã downstream có thể lấy được các kiểu tùy chọn đã chuyển đổi và được chuyên biệt hóa mà không cần Any, casts hoặc suppressions.
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
- tooling
- Loại issue
- Tính năng
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Sôi nổi
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 68/100