pdoc3 / pdoc

:snake: :arrow_right: :scroll: Auto-generate API documentation for Python projects
https://pdoc3.github.io/pdoc/
GNU Affero General Public License v3.0
1.14k stars 146 forks source link

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

Open hhoppe opened 2 years ago

hhoppe commented 2 years ago

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 commented 2 years ago

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]?