-
Notifications
You must be signed in to change notification settings - Fork 46
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
Proposal for code helper to fix the binding docstring to make code documentation and completion happy #461
Open
damienmarchal
wants to merge
28
commits into
sofa-framework:master
Choose a base branch
from
CRIStAL-PADR:xp-component-stubgen
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Proposal for code helper to fix the binding docstring to make code documentation and completion happy #461
damienmarchal
wants to merge
28
commits into
sofa-framework:master
from
CRIStAL-PADR:xp-component-stubgen
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The name was missing. Signed-off-by: Damien Marchal <[email protected]>
I suspect this code to have been integrated in the SofaPython3 by mistake and to have never worked. By looking at it it may be an experiment to allow syntax like this import Sofa.Components Sofa.Components.MechanicalObject() ...
…nows about them. The problem: Depending on the definition order of the binded classes, there may have incorrect types if Base is useing BaseData... but BaseData is only binded after Base. The PR propose a solution for that using a decidcated "forward" registration patter.
…nows about them. The problem: Depending on the definition order of the binded classes, there may have incorrect types if Base is useing BaseData... but BaseData is only binded after Base. The PR propose a solution for that using a decidcated "forward" registration patter.
…nows about them. The problem: Depending on the definition order of the binded classes, there may have incorrect types if Base is useing BaseData... but BaseData is only binded after Base. The PR propose a solution for that using a decidcated "forward" registration patter.
I suspect this code to have been integrated in the SofaPython3 by mistake and to have never worked. By looking at it it may be an experiment to allow syntax like this import Sofa.Components Sofa.Components.MechanicalObject() ...
…-how-to-fix-definition
…definition' into pr-typehint-example-how-to-fix-definition
… xp-component-stubgen
It should be completed if ones want more feature than just class declaration
It should be completed if ones want more feature than just class declaration
…-how-to-fix-definition
…-how-to-fix-definition
# Conflicts: # bindings/Sofa/src/SofaPython3/Sofa/Components/Submodule_Components.h # bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_BaseClass.h # bindings/Sofa/src/SofaPython3/Sofa/Types/Binding_CompressedRowSparseMatrix.h
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently pybind11 generates the function signatures automagically and we use this feature a lot.
The problem is that the automagically generates python signatures with type-hints and that these signatures may be invalid (in fact not narrow enough).
On way to partially tackle the problem is to change de c++ code to help pybind11 to properly produce the correct signatures. In some case this is minor changes on the c++ side, but in some others this may imply massive refactoring.
There is a second issue, when a function should have generic type hint signature (see PEP https://peps.python.org/pep-0695/) there is no way to add that in the automagicall process of pybind11's without changing pybind11 code and have that accepted mainstream.
The proposed alternative was fix manually the failing method signatures. The draw back of the approach was that in that case all the docstring autogenerated are disabled. So we have to write every signature for each overload of a method, even if previously they were correct). In addition it was suggested by @bakpaul to have that done
not directly in the docstring but in the c++ code.
This PR is one possible implementation for such feature.
Instead of the classical (which fails on signature generation):
Should be written this way (with custom signature generation only on the failing one)
The complexity of the code is a result of how pybind11 is doing the magic of binding.