Closed oscargus closed 3 weeks ago
After reading the help-text (someone else set up a script to generate the stubs in my project) I realize that _bar
can be included by the -P
switch, but __version__
is still failing. Using __version__
seems to be a rather common approach?
The doc-string issue still remains (and is the only way I see to actually run doctest on extensions?)
The stripping of newlines is likely intentional (it's been a while since I wrote this code—I think I needed it to deal with some auto-extracted C++ docstrings that were mapped onto Python). As you noticed, there is a flag to include private bits. For the __version__
, I am not sure. Feel free to create a PR if this seriously bothers you, but for now I will close this as won't fix / out of scope.
Problem description
Two issues found in the otherwise very nice and useable stub generator.
_
are dropped. Consider an__init__.py
looking like (_foo
is a nanobind extension):This will generate a stub file
__init__.pyi
like:which then e.g. ruff will complain about since
_bar
and__version__
are seemingly not imported.(Maybe the idea is to only generate stubfiles for
_foo
, but I imagine that there may be cases where this is still useful.)(There is also the thing that generating stub files for
_foo
(extension) will befoo.pyi
, but that can be worked around and I understand why that is done.)"""
are interpreted by doctest to be included in the expected result. Not sure if this is a result of the stubs or the parsing of doc-strings though...Reproducible example code
No response