python / python/typeshed

Preventing code quality regressions

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

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

project: infrastructure
Ngôn ngữ chính
Python
Star
5.1k
Fork
2.1k
Merge trung bình
1 ngày 19 giờ
Pull request đã merge (30 ngày)
82

Mô tả

For some time now we've used pyright's stricter configuration to prevent code quality regressions. Unless a stubs package is mentioned in the config file, it's expected to have annotations for all its fields. While this has served us well for a while, it has become unsuitable since the introduction of _typeshed.Incomplete:

  • pyright doesn't understand that a (partial) Incomplete annotation is equivalent (for our purposes) to an unannotated item.
  • It's tedious to maintain the pyright stricter configuration in addition to the metadata in the stubs directory.
  • It's easy to cheat the regression check by using Incomplete.

To improve the situation, I propose to move to a custom solution:

  1. Add an incomplete marker to METADATA.toml (defaulting to false).
  2. Add a custom script to CI that checks that a stub package marked as complete can't have any incomplete (unannotated or using Incomplete) fields. Alternatively, we could add a disabled-by-default check to flake8-pyi and use that instead.
  3. At a later date, we could also add a PR CI script that add a PR comment warning a user if the amount of incomplete increases due to a PR.

(See also https://alexwaygood.github.io/typeshed-stats/.)

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 bằng việc xem xét siêu dữ liệu của gói stub trong METADATA.toml và các kiểm tra CI hiện tại sử dụng cấu hình nghiêm ngặt hơn của pyright. So sánh việc triển khai một script CI tùy chỉnh với kiểm tra flake8-pyi được đề xuất và bị tắt theo mặc định. Hoàn thành có nghĩa là các gói hoàn chỉnh không thể chứa các trường chưa được chú thích hoặc các trường sử dụng _typeshed.Incomplete, và dấu đánh dấu chưa hoàn chỉnh mặc định là false.

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
ci-cd, 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
Khá rõ ràng
Mức phù hợp với người mới
35/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.