python / python/mypy

Plugin API feature requests

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

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

feature priority-1-normal topic-plugins
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ả

I recently wrote a plugin that used get_function_hook() to intercept instantiations of a certain set of classes (recognized by name), and found a bunch of functionality missing. Here's a list.

  • I needed the names of the arguments but they were not directly available. I ended up using rtype.type.names['__init__'].node.arg_names (with various type and None guards) and subtracting 1 to compensate for self, which looked very hacky. It would be nice if FunctionContext also has an arg_names argument.

  • CheckerPluginInterface has no fail() method. It exists on the implementation, and the similar TypeAnalyzerPluginInterface does define it.

  • I needed to look up a name in the module's global namespace; I ended up calling ctx.api.lookup_qualified() but that's not in the interface, and perhaps it's not the thing to use.

  • I needed the functionality of parse_bool() but it's not there (it only exists on SemanticAnalyzerPluginInterface).

  • I needed something similar to what's in mypy/plugins/common.py as _get_bool_argument() _get_argument() but had to write my own because the starting point was a FunctionContext instead of a ClassDefContext.

  • (Not directly a plugin issue, but this happened.) I was also bitten by the error message The type alias{} is invalid in runtime context -- this seems a bit inconsistent because expanding the Union that the alias references makes it go away. I.e. if A = Optional[int], foo(A) gives that error, but foo(Optional[int]) doesn't.

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

Xem xét các giao diện plugin liên quan đến FunctionContext, CheckerPluginInterface và SemanticAnalyzerPluginInterface, cùng với mypy/plugins/common.py và hành vi runtime của type alias đã được báo cáo. Issue này chứa một số yêu cầu API riêng biệt thay vì một thay đổi có phạm vi duy nhất; để hoàn thành, cần quyết định những yêu cầu nào được hỗ trợ và xác định hành vi mong đợi của chú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
tooling
Loại issue
Tính năng
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
25/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.