enigmatic "name already defined" error

Đang mở
#7,206 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ó
3/5
Thời gian dự kiến
1-2 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
devtools

Hướng nghiên cứu

Trước tiên, hãy chạy bốn bản tái hiện inline với phiên bản mypy được báo cáo, sử dụng test.py cho hàm được import. So sánh các chẩn đoán cho từng thứ tự import và định nghĩa lại. Được xem là hoàn tất khi hành vi nhất quán với kỳ vọng của báo cáo rằng cả bốn trường hợp đều phát ra lỗi duplicate-definition.

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

Mô tả

bug priority-1-normal

Please provide more information to help us understand the issue:

  • Are you reporting a bug, or opening a feature request?

Bug.

  • Please insert below the code you are checking with mypy,
    or a mock-up repro if the source is private. We would appreciate
    if you try to simplify your case to a minimal repro.

There are four pieces of code:

def func(x: int) -> int:
    return x + 1

def func(x):
    return x
def func(x):
    return x

def func(x: int) -> int:
    return x + 1
from test import func

def func(x: int) -> int:
    return x + 1
def func(x: int) -> int:
    return x + 1

from test import func

Whenever test is used as a module, test.py contains

def func(x):
    return x
  • What is the actual behavior/output?

The first three examples emits "Name 'func' already defined" error, but not the last

  • What is the behavior/output you expect?

All four should emit this error.

  • What are the versions of mypy and Python you are using?

mypy 0.720+dev.dc6da54f50d5443fe46308046719043eba03c84d (master at the time of bug report)
Python 3.7.3

  • What are the mypy flags you are using? (For example --strict-optional)

None.

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.