Skip to content
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

gufe objects not giving informative signatures #60

Closed
dwhswenson opened this issue Sep 22, 2022 · 2 comments
Closed

gufe objects not giving informative signatures #60

dwhswenson opened this issue Sep 22, 2022 · 2 comments

Comments

@dwhswenson
Copy link
Member

Our objects are not returning useful signatures. They all return a <Signature (*args, **kwargs)>.

This is annoying when using our objects in IDEs, e.g., using shift-tab for quick help in Jupyter.

Expected behavior would be to see the actual signature coming from the __init__.

I suspect the source of this problem is our metaclass. Specifically, I think we're actually seeing the signature from _GufeTokenizableMeta.__call__. Not an urgent issue, but I wanted to document it since I'm pretty sure I've identified the reason, although I don't have a trivial solution.

In [1]: import inspect

In [2]: import gufe
LICENSE: Could not open license file "oe_license.txt" in local directory
LICENSE: N.B. OE_LICENSE environment variable is not set
LICENSE: N.B. OE_DIR environment variable is not set
LICENSE: No product keys!
LICENSE: No product keys!
LICENSE: No product keys!
LICENSE: No product keys!
g
In [3]: gufe.__version__
Out[3]: 'v0.2.post227+g69ad4d2'

In [4]: inspect.signature(gufe.ChemicalSystem)
Out[4]: <Signature (*args, **kwargs)>

In [5]: inspect.signature(gufe.SmallMoleculeComponent)
Out[5]: <Signature (*args, **kwargs)>

In [6]: inspect.signature(gufe.ProteinComponent)
Out[6]: <Signature (*args, **kwargs)>

In [7]: inspect.signature(inspect.Signature)
Out[7]: <Signature (parameters=None, *, return_annotation, __validate_parameters__=True)>
@dwhswenson
Copy link
Member Author

Of course, someone has asked on SO: https://stackoverflow.com/questions/49740290/call-from-metaclass-shadows-signature-of-init

Looks like we need to modify the __signature__ attribute per PEP 362.

@dwhswenson
Copy link
Member Author

Fixed in #216.

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

No branches or pull requests

1 participant