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

Add support for exporting Signature objects as JSON #289

Merged
merged 1 commit into from
Oct 2, 2023

Conversation

asmeurer
Copy link
Collaborator

The format is compatible with the format produced by Griffe, except we don't use an ast form for the annotations.

The format is compatible with the format produced by Griffe, except we don't
use an ast form for the annotations.
@asmeurer
Copy link
Collaborator Author

Note that this relies on inspect.formatannotation for files that don't use from __future__ import annotations. Don't know how robust that is or if there could be weird annotation objects that it can't handle (although I would expect such things wouldn't be handled well by Sphinx either?)

@asmeurer
Copy link
Collaborator Author

Still need to output this to the actual data files, and add tests.

@Carreau
Copy link
Member

Carreau commented Sep 22, 2023

Thanks, I had forgotten ammit had started this class. I'm guessing it is also not used everywhere and some place are still carrying str signatures.

@Carreau
Copy link
Member

Carreau commented Oct 2, 2023

Thanks, merged and updated as part of #291, one change was that None is a valid annotation so I had to add a workaround between to not serialize and empty annotation as None. Otherwise both def f(a):pass and def f(a:None) would serialize as the same. This was present in annotation and default values. Of course in parameters annotation it's rare, but probably less in return annotations.

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.

2 participants