Hi, my package is called maialib and inside it, I have 2 modules. They are called: maiacore and maiapy.
The maiacore module is a pybind11 compiled module but the maiapy module is just a set of pure Python files.
My goal is to create a Python package that when the user runs import maialib, it will import both maiacore and maiapy.
maialib/
├─ maiacore/
│ ├─ __init__.py
│ ├─ maiacore.cpython.so
│ ├─ __init__.pyi # new file
│ │ ├─ maiacore/ # new folder
│ │ │ ├─ __init__.pyi # new file
├─ maiapy/
│ ├─ __init__.py
│ ├─ __init__.pyi # new file
│ ├─ lib01/ # new folder
│ │ ├─ __init__.pyi # new file
│ ├─ lib01.py
│ ├─ lib02.py
│ ├─ lib03/ # new folder
│ │ ├─ __init__.pyi # new file
│ ├─ lib03.py
My Problem
After install my package using pip install . I start to use it on VS Code v1.75
The maiacore stubs are working perfect
The maiapy stubs are not showing up on VS Code
A Doubt
Looking in the maiapy module, the pybind11-stubgen generated a new folder to lib01.py and lib03.py, but do not did it for the lib02.py. Why this can be happening?
A Way to Investigate
Looking the most external pybind11-stubgen generated __init__.pyi file, I saw that it imports all maiacore classes, but do not import any maiapy file or function.
But, in this same file, the __all__ = [...] variable contains both maiacore and maiapy classes and function names.
Is there any way to "force" pybind11-stubgen to include the lines from maialib.maiapy.libXXX import XYZ like it is already doing with maiacore?
Here is this most external generated __init__.pyi file:
from __future__ import annotations
import maialib
import typing
from maialib.maiacore.maiacore import Barline
from maialib.maiacore.maiacore import Chord
from maialib.maiacore.maiacore import Clef
from maialib.maiacore.maiacore import Duration
from maialib.maiacore.maiacore import HeapData
from maialib.maiacore.maiacore import Helper
from maialib.maiacore.maiacore import Interval
from maialib.maiacore.maiacore import Measure
from maialib.maiacore.maiacore import Note
from maialib.maiacore.maiacore import NoteData
from maialib.maiacore.maiacore import NoteDataHeap
from maialib.maiacore.maiacore import Part
from maialib.maiacore.maiacore import Score
from maialib.maiacore.maiacore import ScoreCollection
import maialib.maiacore.maiacore
# AS YOU CAN SEE, NO 'from maialib.maiapy import XYZ'
__all__ = [
"Barline",
"Chord",
"Clef",
"Duration",
"HeapData",
"Helper",
"Interval",
"Measure",
"Note",
"NoteData",
"NoteDataHeap",
"Part",
"Score",
"ScoreCollection",
"getScoreSamplePath", # HERE IS A MAIAPY FUNCTION NAME
"maiacore",
"maiapy", # HERE IS MAIAPY MODULE
"plotPartsActivity", # HERE IS A MAIAPY FUNCTION NAME
"testFunc", # HERE IS A MAIAPY FUNCTION NAME
"testPlot" # HERE IS A MAIAPY FUNCTION NAME
]
Please, could you help me to generate the correct maiapy*.pyi files in a way that it will be visible on VS Code?
Thank you for your attention!
Now I got that pybind11-stubgen only generates Python stubs for the C++ Pybind11 modules. Not for pure *.py files.
To generate stubs for *.py files I can use mypy
Hi, my package is called
maialib
and inside it, I have 2 modules. They are called:maiacore
andmaiapy
. Themaiacore
module is apybind11
compiled module but themaiapy
module is just a set of pure Python files. My goal is to create a Python package that when the user runsimport maialib
, it will import bothmaiacore
andmaiapy
.My original folder structure is:
Generating Python Stubs
To generated the Python stubs, I'am using this command below:
So now I got this files structure below:
My Problem
After install my package using
pip install .
I start to use it onVS Code v1.75
maiacore
stubs are working perfectmaiapy
stubs are not showing up on VS CodeA Doubt
Looking in the
maiapy
module, thepybind11-stubgen
generated a new folder tolib01.py
andlib03.py
, but do not did it for thelib02.py
. Why this can be happening?A Way to Investigate
Looking the most external
pybind11-stubgen
generated__init__.pyi
file, I saw that it imports allmaiacore
classes, but do not import anymaiapy
file or function. But, in this same file, the__all__ = [...]
variable contains bothmaiacore
andmaiapy
classes and function names. Is there any way to "force"pybind11-stubgen
to include the linesfrom maialib.maiapy.libXXX import XYZ
like it is already doing withmaiacore
?Here is this most external generated
__init__.pyi
file:Please, could you help me to generate the correct
maiapy
*.pyi
files in a way that it will be visible on VS Code? Thank you for your attention!My System