Strange behavior when superclass is an unknown argument

Đang mở
#1,069 4 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
30/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
devtools

Hướng nghiên cứu

Start by reproducing both examples from the issue and compare how annotating cls as Any affects the errors for the class base and super() call. Done means the intended handling of an unknown superclass is established and covered for both forms, with the reported inconsistent diagnostics resolved.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug false-positive priority-1-normal topic-inheritance

Forking this issue from #1067. Example:

def outer(cls):
    class C(cls):  # E: Invalid type "cls"
        def meth(self):
            super(C, self).meth()  # E: "meth" undefined in superclass

Neither error goes away when I annotate the 'cls' argument as having type 'Any'. Also interesting: this gives the same two errors:

cls = ...
class C(cls):  # E: Invalid type "cls"
    def meth(self):
        super(C, self).meth()  # E: "meth" undefined in superclass

but here annotating 'cls' as type 'Any' does make the errors disappear.

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

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 python/mypy

Tất cả issue của python/mypy

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.