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

Added options to retain original typehints in signatures #278

Merged
merged 6 commits into from Jan 5, 2023

Conversation

BhavyeMathur
Copy link
Contributor

I was using this library and noticed that there was no existing way to retain the typehints automatically generated by autodoc in function/class/method signatures. I quite liked the way that return types are annotated with the -> in signatures and wanted to preserve those while using autodoc-typehints.

This pull request adds 2 simple options that do not alter the behaviour of anyone already using typehints:

  1. typehints_use_signature (False by default)
  2. typehints_use_signature_return (False by default)

By setting these, the sph_signature.replace() commands in process_signature() can be altered

With default options:
image

With the new options set to True:
image

Copy link
Member

@gaborbernat gaborbernat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests, please!

@BhavyeMathur
Copy link
Contributor Author

Hey! So I'm new to pull requests and to sphinx. Any particular tests you're looking for?

@gaborbernat
Copy link
Member

Test for all features you've added.

.gitignore Outdated Show resolved Hide resolved
@gaborbernat gaborbernat merged commit 32dc422 into tox-dev:main Jan 5, 2023
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.

None yet

2 participants