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

Documentation shows unexpected ForwardRef(None) inside Union. #395

Closed
hhoppe opened this issue Apr 25, 2022 · 3 comments
Closed

Documentation shows unexpected ForwardRef(None) inside Union. #395

hhoppe opened this issue Apr 25, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@hhoppe
Copy link
Contributor

hhoppe commented Apr 25, 2022

Input:

from typing import Union

def test1_func(arg: Union[None, str, int]) -> None:
  return

Resulting documentation:
def test1_func(arg: Union[ForwardRef(None), str, int]) ‑> None

Expected documentation:
def test1_func(arg: Union[None, str, int]) ‑> None

!pdoc --version
pdoc 0.10.0

@hhoppe
Copy link
Contributor Author

hhoppe commented Apr 26, 2022

Actually, it would be even better (clearer and more concise) if this produced the Python 3.10 syntax:

def test1_func(arg: str | int | None) ‑> None

It seems that pdoc does so some of the time -- maybe only for Optional[simple_type]?

@kernc kernc added the bug Something isn't working label Nov 25, 2024
@kernc kernc closed this as completed in 6e8bdfd Nov 26, 2024
@hhoppe
Copy link
Contributor Author

hhoppe commented Nov 26, 2024

Maybe an option to output int | float | None rather than Optional[int | float]?
It seems to be the modern trend.

kernc added a commit that referenced this issue Nov 26, 2024
Ref: 6e8bdfd ENH: Improve formatting of Optional, Union and collection.abc types
Ref: #395

Thanks @hhoppe
@kernc
Copy link
Member

kernc commented Nov 26, 2024

No options—sane defaults. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

2 participants