document typing.Literal in function/method arguments

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

Maintainer thường phản hồi trong vòng 1 ngày

@has2k1 đang làm issue này rồi.

Từ ngày 19/11/2026.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
68/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
documentation

Hướng nghiên cứu

Start by reading the code that builds function and method signatures for generated documentation, then find its tests for type annotations. Add support for displaying the values from typing.Literal, including None when the annotation is optional. Done looks like generated signatures show the available options and the relevant tests cover this example.

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

Mô tả

Difficulty: [2] Intermediate Effort: [2] Medium Priority: [2] Medium Type: ★ Enhancement

Prework

Proposal

I have functions/methods I want to document that have Literal type annotations, for example:

def do_thing(word: str, projection: Literal["standard", "full"] | None = None) -> dict:
    """Docstring Example"""
    return {}

When I generate docs, it looks like this:

do_thing(
    word,
    projection=None,
)

This isn't ideal - I'd like to to be able to document to a user what the available options are for projection. Could this be updated to show the available options?

Something like this, though it could be flexible:

do_thing(
    word,
    projection: {None, "standard", "full"} = None,
)
Ngôn ngữ chính
Python
Star
282
Fork
24
Merge trung bình
2 giờ 17 phút
Pull request đã merge (30 ngày)
281

Chuẩn bị môi trường

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 posit-dev/great-docs

Tất cả issue của posit-dev/great-docs

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.