"See help(type(self)) for accurate signature" in `__init__`'s docstring is misleading
Ninguém assumiu esta issue ainda.
- Linguagem predominante
- Python
- Estrelas
- 77.2k
- Forks
- 36k
- Métricas de merge de PRs
- Métricas de PR pendentes
Descrição
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?
Guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Direção de pesquisa
Reproduza a saída relatada com help(A), help(A.init) e uma classe B vazia. Rastreie onde a docstring do init integrado e a saída de classe do pydoc são geradas e, em seguida, identifique a área relevante dos testes de regressão. A tarefa estará concluída quando a orientação enganosa for corrigida ou removida de forma consistente e a saída de help estiver coberta por testes.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- python
- Domínio
- documentation
- Tipo de issue
- Funcionalidade
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Status de atividade
- Estagnada
- Clareza
- Razoavelmente clara
- Facilidade para iniciantes
- 35/100