python / python/mypy

Stubgen user documentation of modules

Aperta
#14,094 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

bug topic-stubgen
Lingua principale
Python
Stelle
20.6k
Fork
3.3k
Metriche di merge delle PR
Metriche PR in attesa

Descrizione

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?

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia riproducendo l'esempio di modulo Boost.Python ed eseguendo stubgen -p pyClass, quindi confronta il pyClass.pyi generato con l'output di help(pyClass). Traccia il modo in cui stubgen gestisce i moduli compilati e determina se sia possibile conservare firme, docstring e informazioni sui tipi; il lavoro è completato quando lo stub generato riflette la documentazione disponibile del modulo.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python
Ambito
tooling
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
38/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.