Skip to content

With nanobind, nb_method is like instancemethod, a specific __name__ for methods #13836

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

VincentRouvreau
Copy link

Purpose

Fix #13823
I did not add any unitary test as it would imply to package a class with NanoBind.
But I tested it with this minimal project to reproduce the bug: https://gitlab.inria.fr/vrouvrea/sphinx_nanobind_investigation

This modification makes each method of the class Hello to be seen as a MethodDocumenter and not as AttributeDocumenter

References

This comes from that with C-API (or even PyBind11):

>>> from osmium.io import File # A PyBind11 example
>>> File.__dict__
mappingproxy({'__init__': <instancemethod __init__ at 0x79777556ad40>, '__doc__': None, '__module__': 'osmium.io', 'has_multiple_object_versions': <property object at 0x79777556df30>, 'parse_format': <instancemethod parse_format at 0x79777556ac20>})

But with NanoBind:

>>> from sphinx_nanobind_investigation import Hello # cf. https://gitlab.inria.fr/vrouvrea/sphinx_nanobind_investigation
>>> Hello.__dict__
mappingproxy({'__new__': <built-in method __new__ of nanobind.nb_type_0 object at 0x64ba8b1bc6e0>, '__init__': <nanobind.nb_method object at 0x7977754ddcf0>, '__doc__': 'Hello class', '__module__': 'sphinx_nanobind_investigation.hello_ext', 'speak': <nanobind.nb_method object at 0x7977754df780>, 'date_and_time': <nanobind.nb_func object at 0x7977754df890>, 'name': <nanobind.nb_method object at 0x7977754df9a0>})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

autodoc fails to render C++ methods signatures, while functions are ok
1 participant