python / python/mypy

Option to remove unsupported annotations from `numpy.ndarray` and `List` in stubgen

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

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

feature topic-stubgen
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ả

Feature

Command-line arguments for stubgen that when enabled will remove unsupported annotations from numpy.ndarray and List
like numpy.ndarray[numpy.float32[3,1]] and List[float[3]] which pybind11 outputs.

FYI: This feature has been implemented for numpy.ndarray in pybind11-stubgen.

Pitch

The stubs generated from extensions made with pybind11 using mypy.stubs are invalid when Eigen types or std::array are used in the interface.

As an example, this output from stubgen,

    def as_numpy(self) -> numpy.ndarray[numpy.float32[3,1]]: ...

will give the following errors when used together with Mypy:

error: Bad number of arguments for type alias, expected: 0, given: 2
error: "ndarray" expects 2 type arguments, but 1 given
error: Invalid type: try using Literal[2] instead?
error: Invalid type: try using Literal[1] instead?

And this

def split(axis_aligned_bounding_box: AxisAlignedBoundingBox, max_extents: List[float[3]]) -> List[AxisAlignedBoundingBox]: ...

will give these errors:

error: "float" expects no type arguments, but 1 given
error: Invalid type: try using Literal[3] instead?

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 từ điểm vào dòng lệnh của stubgen và truy vết cách các chú thích như numpy.ndarray[...] và List[...] được phát sinh. Thêm một tùy chọn loại bỏ các chú thích không được hỗ trợ, sau đó xác minh rằng các stub được tạo không còn phát sinh các lỗi mypy đã mô tả.

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

Đánh giá

Công nghệ
numpy, python
Lĩnh vực
cli, devtools, tooling
Loại issue
Tính năng
Độ 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.