MyPy complains if file replaced by shadow-file doesn't exist

Đang mở
#4,746 8 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
tooling

Hướng nghiên cứu

Start by reproducing the three commands in the issue with mypy 0.570 or a current checkout, then trace the --shadow-file argument handling and file-existence checks. Done means a missing source file mapped to an existing shadow file behaves like the shadow file, while an unrelated mapping does not produce a misleading missing-file error.

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

Mô tả

This is a follow-up to https://github.com/python/mypy/issues/2119. I think this a bug report, but maybe it's a feature request, or even possibly a documentation request.

I'm surprised by the following behavior of --shadow-file SOURCE_FILE SHADOW_FILE:

$ cd /tmp/
$ mkdir python
$ cd python/
$ echo "x = 1 + 'A'" > shadow.py
$ mypy --shadow-file error.py shadow.py error.py #1
mypy: can't read file 'error.py': No such file or directory
$ mypy --shadow-file error.py shadow.py shadow.py #2
mypy: can't read file 'shadow.py': No such file or directory
$ mypy shadow.py #3
shadow.py:1: error: Unsupported operand types for + ("int" and "str")

I see two problems here:

  • I expected # (1) to behave just as if there had been a file error.py with the contents of shadow.py, returning the same as # (3). This use case happens concretely when a user of Emacs creates a new file (but hasn't saved it to disk yet). In that case we create a temporary file with the contents of the unsaved file, and pass that as shadow.py, with error.py being the name of the yet-unsaved file.

  • In # (2) I did not expected the --shadow-file option to make a difference, since I remapped error.py to shadow.py and then asked about shadow.py (which shouldn't be affected by the unrelated mapping). Additionally, the error seems wrong (the file shadow.py exists).

I'm using mypy 0.570 and Python 3.5.2 (I have not tried with mypy from git master)

Am I misunderstanding the way --shadow-file is used?

Thanks!

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.