Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Mypy plugin generates incompatible type overloads for @curry decorated functions with TypeVar

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

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
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
tooling

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

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

  • python version: 3.9.7

  • returns version: 0.16.0

  • mypy version: 0.910

  • hypothesis version (if any):

  • pytest version (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

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.

Issue khác của dry-python/returns

Tất cả issue của dry-python/returns

Issue tương tự

Thêm issue về Python

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.