Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Add positional-only parameters

Đang mở
#641 3 bình luận 2 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
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
backend-api-design

Hướng nghiên cứu

Start with PEP 570 and the issue's Point example, then examine how attrs' attrib option and generated repr currently handle parameters. Define the expected positional-only behavior and verify that the example produces Point((0, 1, 2)) rather than Point(_data=(0, 1, 2)).

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

Mô tả

Feature

With PEP 570, positional-only parameters were introduced.
Similarly to keyword-only parameters, I would like to see these as an option for attrs.
One thing that makes them "special" is that the __repr__ method would behave differently for positional-only parameters than it would for regular positional parameters.

An example I would use in my libraries:

from attr import attrib, attrs


@attrs(auto_attribs=True)
class Point:
    """A three-dimensional point."""
    _data: Tuple[float, float, float] = attrib(positional_only=True)


print(Point((0, 1, 2)))

The output would then be

Point((0, 1, 2))

instead of

Point(_data=(0, 1, 2))

If this were a desirable feature, would this be a good "first pull request" I could follow up on?

Ngôn ngữ chính
Python
Star
5.8k
Fork
480
Merge trung bình
2 giờ 15 phút
Pull request đã merge (30 ngày)
2

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.

Issue khác của python-attrs/attrs

Tất cả issue của python-attrs/attrs

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.