Open s-sajid-ali opened 1 year ago
Thanks for finding and reporting this!
It might be that this can be simpler and we just need to add some __repr__
/__str__
and doc strings of similar kinds to Series
. It is otherwise imported like all the other classes you saw in your screenshot on Slack. Uploading here so we see what it already detects:
Aren't all the detected items the the objects present here: https://github.com/openPMD/openPMD-api/blob/9a215b20b48abc9275ef53306cfd5e357bf86ed5/src/binding/python/openpmd_api/__init__.py#L1-L18
Is there a way to tell intellisense to follow this line? https://github.com/openPMD/openPMD-api/blob/9a215b20b48abc9275ef53306cfd5e357bf86ed5/src/binding/python/openpmd_api/__init__.py#L5
Maybe it generally ignores that.
Otherwise we could consider looping over the imported dicts and adding them to __all__
or so, but that's a bit much for a functionally correct workflow that confuses an IDE
No sure about intellesense
but a different static type checker, mypy
states:
Mypy can use a stub file instead of the real implementation to provide type information for the module. They
are useful for third-party modules whose authors have not yet added type hints (and when no stubs are
available in typeshed) and C extension modules (which mypy can’t directly process).
which makes me guess that the answer to your question is no, though I'd have to read more about how pyright
or intellesense
works to be sure.
Hm, I see, they don't query the extension module at all? Why not I wonder, it's available like any other class... So we need stubs I guess and a workflow to not have to create them manually all the time we change the bindings.
One example on how to do so is here https://github.com/pybind/pybind11/issues/2350#issuecomment-1126255196, and I haven't kept up with how build systems have been working to provide this functionality.
I started working on this in pyAMReX and then will propagate the solution to here, too. https://github.com/AMReX-Codes/pyamrex/pull/184
Currently, the
openpmd-api
module confuses static type checkers likepyright
:Inspecting the
openpmd-api
module viainspect
anddir
using the following:I see
However, if I use the LSP command to go to the definition of the
openpmd-api
module, I am directed to this__init__.py
in the install directory which is missing the definition forSeries
.Proposed fix
Per https://github.com/pybind/pybind11/issues/2350, this can be fixed by using
pybind11-stubgen
/mypy-stubgen
/etc to generate the stubs.Documents of interest