Prevent _GufeTozenizableMeta.__call__
from overwriting signature of __init__
#216
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.
When the
inspect
module of the standard library is used to get the signature of aGufeTokenizable
class, it sees that the metaclass has an implementation of__call__
and takes the signature from that instead of from the__new__
or__init__
method of the child class:This results in unhelpful API documentation:
But also may affect the signature displayed by IDEs, the Jupyter
help
magic, and so on.This PR restores the signature from
__init__
or__new__
when a child class is created:(I've taken screenshots from the GUFE docs, but this problem affects the OpenFE docs as well, and this solution fixes them too)
See https://stackoverflow.com/questions/49740290/call-from-metaclass-shadows-signature-of-init. I originally wrote a solution defining a
__signature__
property on the metaclass, but this solution seems more... canonical.