mypy sometimes emits fewer errors when running on multiple files at once

Đang mở
#14,348 0 bình luận 1 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
compilers

Hướng nghiên cứu

Giải nén repro.zip và chạy hai lệnh trong báo cáo với foo.py và bar.py để tái hiện các chẩn đoán khác nhau. Theo dõi cách các import của mymodule.a và mymodule.b được xử lý khi các tệp được kiểm tra cùng nhau, sau đó đảm bảo rằng lỗi thiếu thuộc tính vẫn được báo cáo trong cả hai lần gọ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

Hello there,

I am witnessing (rare) cases where mypy emits fewer errors when running on multiple files at the same time than when running on each file individually.

More specifically, I noticed that mypy can fail to report an error when an import for a submodule is missing a one file but present in another file.

I failed to find anything relevant in the documentation or in the existing issues, so I thought I'd let you know. Below is my attempt at a minimal reproducible example.

To Reproduce

(Since multiple files are needed, here is an archive with the reproduction case: repro.zip)

Given a module mymodule with nested modules a and b, and this file foo.py:

import mymodule.a


def blah() -> None:
    mymodule.b.fn()


blah()

As expected, when called on foo.py, mypy emits an error:

$ mypy --cache-dir /dev/null foo.py
foo.py:5: error: Module has no attribute "b"
Found 1 error in 1 file (checked 1 source file)

yet if I add to mypy's command line a second file which does import mymodule.b, say bar.py:

import mymodule.b

then mypy does not emit the error any more, even though I would expect it to:

$ mypy --cache-dir /dev/null foo.py bar.py
Success: no issues found in 2 source files

Your Environment

I used mypy 0.991 on Ubuntu 22.04 with python 3.10.6; I can reproduce this behavior with master, as well as python 3.8, and older versions of mypy.

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.