mypy does not show error in excluded folder when PYTHONPATH set
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
Hướng nghiên cứu
Bắt đầu với bố cục package được tái hiện, chứa excluded_folder/excluded.py và included_folder/included.py, sau đó so sánh hai lệnh mypy có và không có PYTHONPATH=. Theo dõi cách --exclude và các module được import được phát hiện. Được xem là hoàn tất khi lần gọi với PYTHONPATH=. báo cáo giá trị trả về không tương thích trong excluded.py, với một regression test bao phủ cả hai lệnh.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Bug Report
As far as I understand, when I use the exclude setting for some folder mypy should still show errors in these packages when imported, because of the follow imports logic. However, if I set the PYTHONPATH to the current working directory, it does not show these errors anymore.
To Reproduce
Here is the folder structure:
src/
|--excluded_folder/
| |-- excluded.py
| |-- __init__.py
|--included_folder/
|-- included.py
|-- __init__.py
The contents of the file excluded.py are as follows:
def function() -> str: # obviously wrong return type
return 5
File included.py looks like so:
from excluded_folder.excluded import function
print(function)
Now, if i run mypy like so, with the setting to exclude the excluded folder, it reports this:
$ mypy --strict --exclude excluded_folder src
src/excluded_folder/excluded.py:3: error: Incompatible return value type (got "int", expected "str") [return-value]
Found 1 error in 1 file (checked 2 source files)
This is what i would expect. It still shows the errors in the file, although excluded.
But if i run mypy with PYTHONPATH set to the current working directory, it does not show any error anymore:
% PYTHONPATH=. mypy --strict --exclude excluded_folder src
Success: no issues found in 2 source files
Expected Behavior
Mypy should also show the errors when the PYTHONPATH is set.
Actual Behavior
Mypy does not show the errors when the PYTHONPATH is set.
Your Environment
- Mypy version used:
mypy 1.8.0 (compiled: yes) - Mypy command-line flags: see commands above
- Mypy configuration options from
mypy.ini(and other config files): none - Python version used: Python 3.11.3
- 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ó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
qgis/QGIS-Documentation#11275 ·
-
bug priority:normal ready-for-dev
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
OpenHands/extensions#626 · 1 bình luận ·
-
Change observation tooltip text Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
CSCfi/sd-search-api#39 ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
-
please add to porn list Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
StevenBlack/hosts#3255 ·