bug inferring signatures from docstrings in stubgenc
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Python
- Estrellas
- 20.6k
- Forks
- 3.3k
- Métricas de merge de PR
- Métricas de PR pendientes
Descripción
Bug Report
When generating stubs from c modules, stubgen uses mypy.stubdoc to parse signatures from docstrings, if they are present, however, this does not work if the function takes no arguments
To Reproduce
Function with args:
>>> from mypy.stubdoc import infer_sig_from_docstring
>>> infer_sig_from_docstring('func(x) -> int', 'func')
[FunctionSig(name='func', args=[ArgSig(name='x', type=None, default=False)], ret_type='int')]
Function without args:
>>>: infer_sig_from_docstring('func() -> int', 'func')
[] # <--- no signature!!!!
The fact that no signatures are returned means that the stubs that are generated look like this:
def func(*args, **kwargs) -> Any
...
But given that we have a docstring with a valid signature, the stubs should look like this:
def func() -> int
...
This seems like a bug. I'll make a PR to fix this when I have some time.
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Empieza con mypy.stubdoc.infer_sig_from_docstring y reproduce los dos ejemplos del issue; después, sigue cómo stubgen utiliza las firmas devueltas. Se considera terminado cuando un docstring sin argumentos como func() -> int produce una firma y stubgen genera el stub de función tipado correspondiente en lugar de un fallback de *args/**kwargs.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- devtools
- Tipo de issue
- Error
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Estado de actividad
- Estancado
- Claridad
- Bien especificado
- Aptitud para principiantes
- 45/100