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

Option for display mode of Optional[Union]. #10773

Open
Sangwon91 opened this issue Aug 17, 2022 · 1 comment
Open

Option for display mode of Optional[Union]. #10773

Sangwon91 opened this issue Aug 17, 2022 · 1 comment
Labels
type:enhancement enhance or introduce a new feature

Comments

@Sangwon91
Copy link

Is your feature request related to a problem? Please describe.
If I use typehints like this, I get the same result as expected from the documentation.

in code:

def func(value: int | str)
    pass

in documentation:

value (int | str) - description about value.

But adding None converts it to a hard-to-read form.
in code:

def func(value: int | str | None = None)
    pass

in documentation:

value (Optional[Union[int, str]]) - description about value.

I think the output should look like this.

value (int | str | None) - description about value.

Does Sphinx already have these features? If not, it would be nice if Sphinx implemented such a feature.

@Sangwon91 Sangwon91 added the type:enhancement enhance or introduce a new feature label Aug 17, 2022
@jbms
Copy link
Contributor

jbms commented Sep 6, 2022

This has been implemented in the sphinx-immaterial theme:

https://jbms.github.io/sphinx-immaterial/apidoc/python/index.html#confval-python_transform_type_annotations_pep604

You might consider creating a pr to upstream that feature into sphinx itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:enhancement enhance or introduce a new feature
Projects
None yet
Development

No branches or pull requests

3 participants