Support `Any` as an alias for `object` to describe a default typeclass implementation
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 38/100
Hướng nghiên cứu
Issue không nêu tên các tệp triển khai hoặc các bài kiểm thử. Hãy bắt đầu bằng cách tìm phần xử lý phía sau @render.instance(object) và các bài kiểm thử instance của typeclass hiện có, sau đó lần theo cách object default được nhận diện. Được xem là hoàn tất khi @render.instance(Any) hoạt động tương đương với @render.instance(object), trong khi ví dụ dispatch implementation fallback.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Context. In order to define a default implementation (the one used if no other implementation matches), we currently have to write something like this:
from classes import typeclass
@typeclass
def render(data_value) -> str:
"""Render a data value nicely."""
@render.instance(int)
def _render_int(data_value: int) -> str:
return f'This is an integer: {data_value}'
@render.instance(object)
def _render_int(data_value: object) -> str:
return f'No idea what this is: {data_value}'
assert render('BADOOM') == 'No idea what this is: BADOOM'
(this script should be runnable as-is.)
Decision. Support Any as a special case to replace object:
@render.instance(Any)
def _render_int(data_value: Any) -> str: # type: ignore
return f'No idea what this is: {data_value}'
Consequences.
- Pro: The code will look a little bit more straightforward;
- Contra:
mypywith common settings might be unhappy aboutAnybeing used, but that can be silenced withtype: ignoreI suppose.
- Ngôn ngữ chính
- Python
- Star
- 730
- Fork
- 30
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
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.
Issue khác của dry-python/classes
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
dry-python/classes#496 ·
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 45/100
dry-python/classes#494 ·
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 52/100
dry-python/classes#492 · 2 bình luận ·
-
bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
dry-python/classes#481 · 5 bình luận · 4 reaction ·
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 35/100
dry-python/classes#386 ·
Tất cả issue của dry-python/classes
Issue tương tự
-
Add: hunch Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
AbdelStark/awesome-typesafe#104 ·
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
DiamondLightSource/dodal#2211 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
openml/openml-python#1749 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
sipyourdrink-ltd/bernstein#6191 ·