[Generics] Multiple callable arguments to function generate incompatible type error
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
- 42/100
Hướng nghiên cứu
Start by reproducing the supplied generic and Callable example with the stated mypy command, comparing the two-argument and one-argument signatures. Trace the type-checking path for callable argument inference; done means the two-argument form no longer reports the misleading incompatible-type error while the behavior remains covered by a regression test.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
from typing import TypeVar, Generic, Callable
A = TypeVar('A')
B = TypeVar('B')
E = TypeVar('E', bound=BaseException)
class Child(Generic[A]):
def __init__(self, x):
# type: (E) -> None
self.x = x
def fun(self, s, f):
# type: (Callable[[A], Child[B]], Callable[[E], Child[B]]) -> Child[B]
return f(self.x) # <----- error here
test_py.py:15: error: Argument 1 has incompatible type "E"; expected "E"
Kind of misleading, and I think it is a bug.
Interesting thing is that when you remove the 's' argument and it's part in type comment so it becomes like this :
def fun(self, f):
# type: (Callable[[E], Child[B]]) -> Child[B]
return f(self.x)
then there is no error.
command: <file_path> --strict-optional --warn-no-return --warn-redundant-casts --check-untyped-defs --disallow-untyped-defs --py2
mypy version: 0.511
os: Ubuntu 16.10
- Ngôn ngữ chính
- Python
- Star
- 20.6k
- Fork
- 3.3k
- Merge trung bình
- 1 ngày 18 giờ
- Pull request đã merge (30 ngày)
- 54
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 python/mypy
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
-
documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
bug topic-configuration topic-error-reporting
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
zostera/django-bootstrap4#894 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
use-agent-os/agent-os#3276 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
zephyrproject-rtos/zephyr#119726 ·
-
area/auth bug comp/agent P3 platform/discord type/security
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
NousResearch/hermes-agent#117848 ·