python / python/cpython

Move getmethparlist function from turtle to inspect module

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

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

stdlib topic-tkinter type-feature
Ngôn ngữ chính
Python
Star
77.2k
Fork
35.9k
Chỉ số merge pull request
Chỉ số pull request đang chờ

Mô tả

Feature or enhancement

Proposal:

The getmethpartlist turtle module function does work which seems to be supposed to be done by the inspect module.

In fact, getmethpartlist calls inspect.signature and then iterates over it to produce a call to the callable. Perhaps this second part could also be implemented in the inspect module.

In an issue, @terryjreedy said, “For calls that just want the call signature, I wonder if calling getmethodparlist could be replaced by calling signature.”

So, my suggestion is to add two new methods to Signature class, which:

  1. Returns the call:
class Signature():
    def as_call(self) -> string : ...
  1. Returns a new Signature without the first parameter if ob is a method:
class Signature():
    def as_function(self): ...

Then, getmethpartlist could be:

def getmethpartlist(ob):
    defs = inspect.signature(ob).as_function()
    call = defs.as_call()
   return str(defs), call

Thoughts?

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

https://discuss.python.org/t/move-getmethparlist-function-from-turtle-to-inspect-module/97172

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

Trước tiên, hãy xem xét getmethpartlist trong Lib/turtle.py và API inspect.Signature hiện có. Đọc cuộc thảo luận được liên kết và bình luận trước đó của issue để xác định liệu việc tạo lời gọi và xử lý tham số phương thức có thuộc về inspect hay không. Công việc được xem là hoàn tất khi đã thống nhất API và hành vi trước khi có thể xác định phạm vi triển khai.

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
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
Sôi nổi
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
38/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.