python / python/mypy

Per-module options patterns starting with *

Đang mở
#8,522 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

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

bug priority-2-low topic-configuration
Ngôn ngữ chính
Python
Star
20.6k
Fork
3.3k
Chỉ số merge pull request
Chỉ số pull request đang chờ

Mô tả

Hi,
I am experimenting with per-module options and came across weird behavior when module patterns start with star. Documentation does not explicitly say if this is allowed or not, but I would assume it would work the same way as if it was "in the middle" of pattern. And IMHO there is no reason not to support it.

First issue:

From documentation:

Stars match zero or more module components

This is not the case for stars at the start of the string. For example [mypy-*.foo.bar] does not match module foo.bar

>>> import re
>>> from mypy.options import Options
>>> pattern = Options().compile_glob("*.foo.bar")
re.compile('.*\\.foo\\.bar\\Z')
>>> bool(re.match(pattern, "foo.bar"))
False

Second issue:

[mypy-*] does not match anything. I know that it does not make sense to use this since it is the same as global config, but it would be nice to work nonetheless.

In this case it is a bit more difficult: compile_glob returns correct re.compile('.*\\Z'), but there is some flawed logic in build_per_module_cache(), where it gets to concrete section since it does not end with ".*"


Python: 3.7.2
Mypy: 0.770

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

Bắt đầu trong mypy/options.py với Options.compile_glob() và build_per_module_cache(), sau đó tái hiện hai ví dụ từ issue cho *.foo.bar và *. Kiểm tra cách các mẫu được phân loại và đảm bảo các mẫu có dấu sao ở đầu hoạt động nhất quán với quy tắc được ghi trong tài liệu rằng dấu sao khớp với không hoặc nhiều thành phần mô-đun.

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ó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
45/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.