Consider adding a "TopLevel" keyword that stands in for the top level bound of a corresponding type variable

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

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

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
25/100
Loại issue
Tính năng
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
devtools

Hướng nghiên cứu

Bắt đầu với các tests được liên kết là tests/test_flatten.py và tests/distribution_info.py để hiểu thông tin kiểu nào bị mất khi sử dụng DistributionInfo[Any, Any, Any]. Làm rõ ngữ nghĩa đệ quy dự kiến của TopLevel và điểm khác biệt của nó so với hành vi hiện có của biến kiểu. Công việc được xem là hoàn tất khi đề xuất có đặc tả chính xác và một phương án xác thực đã được thống nhất.

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

Mô tả

topic: feature

Summary

Please consider a new typing keyword that stands in for the top level type of a corresponding type variable.

Motivation

Consider a test here and the corresponding definition of DistributionInfo here. The test loses all typing information because I used DistributionInfo[Any, Any, Any]. So if I want typing information, I have to use:

def test_flatten(generator: Generator,
                 distribution_info: DistributionInfo[NaturalParametrization[ExpectationParmetrization, JaxComplexArray],
                                                     ExpectationParametrization[NaturalParmetrization],
                                                     NumpyComplexArray]) -> None:

I would much rather just do

def test_flatten(generator: Generator,
                 distribution_info: DistributionInfo[TopLevel, TopLevel, TopLevel]) -> None:

It's not just shorter, but it reduces churn if the type definitions change. Note that TopLevel is recursive (it chooses the top level of the nested types too).

Ngôn ngữ chính
Python
Star
1.8k
Fork
302
Merge trung bình
23 giờ
Pull request đã merge (30 ngày)
8

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

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/typing

Tất cả issue của python/typing

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.