python / python/mypy

Stubgen user documentation of modules

Abierto
#14,094 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

bug topic-stubgen
Lenguaje dominante
Python
Estrellas
20.6k
Forks
3.3k
Merge medio
1 d 18 h
PR fusionados (30 d)
54

Descripción

I have a boost compiled module pyClass if i import the class and check the documentation of the class using the help function:

>>> import pyClass
>>> help(pyClass)
Help on module pyClass:

NAME
    pyClass

CLASSES
    Boost.Python.instance(builtins.object)
        MyClass

    class MyClass(Boost.Python.instance)
     |  Method resolution order:
     |      MyClass
     |      Boost.Python.instance
     |      builtins.object
     |
     |  Static methods defined here:
     |
     |  __init__(...)
     |      __init__( (object)arg1, (str)arg2) -> None :
     |
     |          C++ signature :
     |              void __init__(struct _object * __ptr64,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)
     |
     |  __reduce__ = <unnamed Boost.Python function>(...)
     |
     |  __repr__(...)
     |      __repr__( (MyClass)arg1) -> str :
     |
     |          C++ signature :
     |              class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __repr__(class MyClass)
     |
     |  foo(...)
     |      foo( (MyClass)arg1, (int)a [, (str)b [, (int)c [, (float)d]]]) -> int :
     |          f's docstring
     |
     |          C++ signature :
     |              int foo(class MyClass {lvalue},int [,char [,unsigned int [,double]]])
     |
     |  ----------------------------------------------------------------------
     |  Data descriptors defined here:
     |
     |  name
     |
     |  number
     |
     |  valueReadOnly
     |
     |  ----------------------------------------------------------------------
     |  Data and other attributes defined here:
     |
     |  __instance_size__ = 80
     |
     |  ----------------------------------------------------------------------
     |  Static methods inherited from Boost.Python.instance:
     |
     |  __new__(*args, **kwargs) from Boost.Python.class
     |      Create and return a new object.  See help(type) for accurate signature.
     |
     |  ----------------------------------------------------------------------
     |  Data descriptors inherited from Boost.Python.instance:
     |
     |  __dict__
     |
     |  __weakref__

FILE
    d:\documents\development\cpp\pythonclib\install\lib\python\cpppythonlib\pyclass.pyd

All the type information is in the module like function parameters and doc strings.

If i run stubgen -p pyClass the resulting file pyClass.pyi doesn't contain any of this information

from typing import Any, ClassVar

import Boost.Python

class MyClass(Boost.Python.instance):
    __instance_size__: ClassVar[int] = ...
    name: Any
    number: Any
    @classmethod
    def __init__(cls, *args, **kwargs) -> None: ...
    @classmethod
    def foo(cls, *args, **kwargs) -> Any: ...
    @classmethod
    def __reduce__(cls) -> Any: ...
    @property
    def valueReadOnly(self) -> Any: ...

Is this information not parsed by stubgen?

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Empieza reproduciendo el ejemplo de módulo de Boost.Python y ejecutando stubgen -p pyClass; después, compara el pyClass.pyi generado con la salida de help(pyClass). Sigue cómo gestiona stubgen los módulos compilados y determina si se pueden conservar las firmas, las cadenas de documentación y la información de tipos; se considera terminado cuando el stub generado refleja la documentación disponible del módulo.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
python
Área
tooling
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
38/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.