Mypy plugin generates incompatible type overloads for @curry decorated functions with TypeVar
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Bắt đầu với reproducer sử dụng TypeVar, @curry, IO và mypy, rồi so sánh các overload được tạo cho _union_sets và _concat_objs với các lỗi đã báo cáo. Truy vết điểm vào của quá trình tạo overload trong plugin curry và thêm một kiểm tra hồi quy cho thấy cả hai hàm đã curry đều kiểm tra kiểu thành công với các chữ ký Callable mong đợi.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Bug report
What's wrong
returns mypy plugin generate incorrect type overloads for curry decorated function with TypeVar arguments
Code to reproduce issue:
from typing import TypeVar
from returns.curry import curry
from returns.io import IO
_T = TypeVar('_T', int, str)
@curry
def _union_sets(first_set: set[_T], second_set: set[_T]) -> set[_T]:
return first_set.union(second_set)
@curry
def _concat_objs(first: _T, second: _T) -> _T:
return first + second
set_1 = IO({1, 2, 3})
set_2 = IO({3, 4, 5})
union = set_1.apply(set_2.apply(IO(_union_sets)))
string_1 = IO('a')
string_2 = IO('b')
concat = string_1.apply(string_2.apply(IO(_concat_objs)))
Mypy gives incompatible type overloaded function error for both curried functions:
error: Argument 1 to "IO" has incompatible type overloaded function; expected "Callable[[Set[int]], Callable[..., Set[_T]]]" [arg-type]
error: Argument 1 to "IO" has incompatible type overloaded function; expected "Callable[[Set[int]], Callable[[Set[int]], Set[_T]]]" [arg-type]
error: Argument 1 to "IO" has incompatible type overloaded function; expected "Callable[[str], Callable[..., _T]]" [arg-type]
error: Argument 1 to "IO" has incompatible type overloaded function; expected "Callable[[str], Callable[[str], _T]]" [arg-type]
How is that should be
Type overloads for functions with TypeVar's should be generated correctly
System information
-
pythonversion: 3.9.7 -
returnsversion: 0.16.0 -
mypyversion: 0.910 -
hypothesisversion (if any): -
pytestversion (if any):
- Ngôn ngữ chính
- Python
- Star
- 4.4k
- Fork
- 154
- Merge trung bình
- 3 giờ 5 phút
- Pull request đã merge (30 ngày)
- 22
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/returns
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
dry-python/returns#2394 · 1 reaction ·
-
Composing 0-argument functions Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 52/100
dry-python/returns#2365 ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
dry-python/returns#2355 · 1 bình luận ·
-
bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
dry-python/returns#2295 · 4 bình luận · 1 reaction ·
-
bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
dry-python/returns#2253 · 2 bình luận ·
Tất cả issue của dry-python/returns
Issue tương tự
-
bug confirmed issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
open-webui/open-webui#30750 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
OpenwaterHealth/openmotion-bloodflow-app#604 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
good first issue
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100