"See help(type(self)) for accurate signature" in `__init__`'s docstring is misleading
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
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?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the reported output with help(A), help(A.init), and an empty class B. Trace where the built-in init docstring and pydoc class output are generated, then identify the relevant regression-test area. Done means the misleading guidance is corrected or removed consistently and the help output is covered by tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- documentation
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100