python / python/cpython

Move getmethparlist function from turtle to inspect module

未关闭
#137,387 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

stdlib topic-tkinter type-feature
主要语言
Python
星标
77.2k
派生
35.9k
PR 合并指标
PR 指标待抓取

描述

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

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先检查 Lib/turtle.py 中的 getmethpartlist 以及现有的 inspect.Signature API。阅读链接的讨论和之前的 issue 评论,以确定调用生成和方法参数处理是否应归入 inspect。在确定实现范围之前,必须先达成一致的 API 和行为,这才算完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
tooling
Issue 类型
功能
难度
5/5
预计耗时
一周以上
活跃度
活跃
描述清晰度
需要澄清
新手友好度
38/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。