sizmailov / python_example

Example pybind11 module built with a Python-based build system
Other
0 stars 0 forks source link

On the way to [pybind11-mypy-demo] #1

Open sizmailov opened 3 years ago

sizmailov commented 3 years ago

Pybind demo module

Basics

Stubgen features

Render values:

Render class/static members

Correct order of module elements

Render docstrings

Proper imports

Corner cases

Robustness to bad docstrings

Misc things to test (unordered) - exclude umbrella `(*args, **kwargs)` overload header from overload list - static/class functions and ro/rw properties - regular ro/rw properties - kw-only function arguments - positional-only function arguments - non-constructable types (with missing `__init__`) - numpy arrays (how to handle shape?) - don't produce import statement for nested classes - (?) exclude `__hash__ = None` line for non-hashable types that have `__eq__` - (?) test nested class argument defined in submodule - import names that not defined in module as underscored aliases - test copy/opaque pybind types (including `pybind11/stl.h` and `pybind11/stl_bind.h`) - test registered exception render - render classes in alpha-topological order (so `ZBase` class would go before `ADerived` but `Cat` goes before `Dog`) - render functions after classes - render module attributes that depend on the following classes with string types annotation (e.g. `x: 'Foo' = ...`) - fix pybind versions (e.g. replace `iterator` with `Iterator`) - skip pybind11-internal attributes - render pybind-overloaded "magic" python methods (e.g. `__add__`) - [optional] render docstrings
YannickJadoul commented 3 years ago
  • render pybind-overloaded "magic" python methods (e.g. __add__)

One easy way of getting this is with an enum_ with py::arithmetic.

Another suggestion: something that's stl_bind.h-bound?

It's hard to think of more things out of the blue, though. It might just be worth trying out some libraries, after the basics work? Happy to help out, there :-)

sizmailov commented 3 years ago

Thanks for commenting. I had in mind stl types, but wrote them as "copy/opaque" types in the list, now it's explicit :smile:

YannickJadoul commented 3 years ago

Yeah, I just had a quick look. It's hard to get a good overview, but if some/most of these things are already working and tested, that's already an amazing amount of progress ;-)