"See help(type(self)) for accurate signature" in `__init__`'s docstring is misleading
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 77.2k
- Forks
- 35.9k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
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?
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Reproduziere die gemeldete Ausgabe mit help(A), help(A.init) und einer leeren Klasse B. Verfolge, wo die Docstring des eingebauten init und die pydoc-Klassenausgabe erzeugt werden, und identifiziere den relevanten Bereich für Regressionstests. Erledigt ist die Aufgabe, wenn die irreführende Anleitung konsistent korrigiert oder entfernt wurde und die help-Ausgabe durch Tests abgedeckt ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- documentation
- Issue-Typ
- Feature
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100