False-positive with multiple *args splats in a function call
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Python
- Star
- 20.6k
- Fork
- 3.3k
- Chỉ số merge pull request
- Chỉ số pull request đang chờ
Mô tả
Bug Report
mypy falsely(?) reports a type error when the *args syntax is used more than once in a function call.
To Reproduce
mypy --no-incremental --config /dev/null -c '
def foobar(a: int, b: str, c: int) -> None:
...
foo = (1,)
bar = ("b", 3)
foobar(*foo, *bar)
'
Expected Behavior
Success: no issues found in 1 source file
Actual Behavior
<string>:9: error: Argument 2 to "foobar" has incompatible type "*Tuple[str, int]"; expected "str"
<string>:9: error: Argument 2 to "foobar" has incompatible type "*Tuple[str, int]"; expected "int"
This error goes away if I:
- make
fooanintinstead ofTuple[int], and remove the splat whenfoobar()is called. - make
bartwo ints and makefoobar()take three int arguments. - make
fooaTuple[str, int]and makefoobar()takestr, int, str, intarguments. - make
barjust aTuple[str]and makefoobar()takeint, strarguments.
Your Environment
This occurs with the standard version of mypy in Debian Testing:
$ /usr/bin/mypy --version
mypy 0.812
...as well as with the latest git revision:
$ ~/.local/pipx/venvs/mypy/bin/mypy --version
mypy 0.820+dev.8642b351cff94c471333256f9cd6867807384f01
In both cases, I'm using the Debian-provided Python 3.9.2,
on up-to-date Debian Testing.
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 bằng cách chạy lệnh mypy được cung cấp và xác nhận hai chẩn đoán cho lời gọi có nhiều tuple splat. Theo dõi việc kiểm tra các đối số của lời gọi và xử lý tuple splat, sau đó thêm độ bao phủ cho reproducer này; hoàn thành khi lệnh không báo cáo vấn đề nào mà không gây hồi quy cho các biến thể được liệt kê.
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
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- 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
- 45/100