"See help(type(self)) for accurate signature" in `__init__`'s docstring is misleading
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 35.9k
- PR 合并指标
- PR 指标待抓取
描述
Feature or enhancement
Let's say I have a simple class:
class A:
def __init__(self, a):
self.a = a
help(A) will produce:
Help on class A in module __main__:
class A(builtins.object)
| A(a)
|
| Methods defined here:
|
| __init__(self, a)
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
Note that the signature is already accurate. But, now I see this message: See help(type(self)) for accurate signature.. Let's try to do something about it.
Let's follow the instruction:
class A:
def __init__(self, a):
help(type(self))
self.a = a
It will produce:
Help on class A in module __main__:
class A(builtins.object)
| A(a)
|
| Methods defined here:
|
| __init__(self, a)
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
Exactly the same signature. With exactly the same message.
Now, let's try a different example, an empty class:
class B: ...
help(B.__init__) will say:
Help on wrapper_descriptor:
__init__(self, /, *args, **kwargs) unbound builtins.object method
Initialize self. See help(type(self)) for accurate signature.
And help(B) will say (notice that there would be no __init__ at all):
Help on class B in module __main__:
class B(builtins.object)
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
Is this message See help(type(self)) for accurate signature really useful? When do users benefit from seeing it?
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
使用 help(A)、help(A.init) 和一个空类 B 重现报告的输出。跟踪内置 init 的文档字符串和 pydoc 类输出的生成位置,然后确定相关的回归测试区域。完成标准是:误导性的指导得到一致的更正或移除,并且 help 输出有测试覆盖。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- documentation
- Issue 类型
- 功能
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100