python / python/mypy

Mypy does not recheck files when follow_imports changes for dependencies

Đang mở
#7,777 3 bình luận 1 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

bug priority-0-high topic-fine-grained-incremental
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

Mô tả

Steps to reproduce
  1. Create module test.py with import from nonexistent module:
from foo import bar
  1. Create mypy.ini file:
[mypy]

[mypy-foo]
ignore_missing_imports = True 
  1. Run mypy
$ mypy test.py 
Success: no issues found in 1 source file
  1. Comment out [mypy-foo] section in mypy.ini
[mypy]

# [mypy-foo]
# ignore_missing_imports = True 
  1. Run mypy
$ mypy test.py 
Success: no issues found in 1 source file
Expected result

After step 4, mypy should detect config change and (partially?) invalidate cache, leading to a type error.

$ mypy test.py 
test.py:1: error: Cannot find module named 'foo'
test.py:1: note: See https://mypy.readthedocs.io/en/latest/running_mypy.html#missing-imports
Found 1 error in 1 file (checked 1 source file)
Notes
  • Deleting .mypy_cache/ and re-running mypy fixes the issue.
  • Adding/removing ignore_missing_imports in the main [mypy] section does seem to invalidate the cache as expected. So this issue only seems to apply to [mypy-PATTERN] sections.
Versions
$ python --version
Python 3.7.3
$ mypy --version
mypy 0.740

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.

Hướng nghiên cứu

Tái hiện vấn đề với test.py, mypy.ini và thư mục .mypy_cache/ bằng các bước cấu hình được cung cấp. Bắt đầu bằng cách theo dõi việc vô hiệu hóa cache đối với các section [mypy-PATTERN] và so sánh với những thay đổi trong section chính [mypy]. Được coi là hoàn tất khi việc thay đổi section pattern khiến mypy báo cáo module foo bị thiếu mà không cần xóa cache thủ công.

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
Đặc tả rõ ràng
Mức phù hợp với người mới
48/100

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.