pdoc icon indicating copy to clipboard operation
pdoc copied to clipboard

Documentation shows unexpected ForwardRef(None) inside Union.

Open hhoppe opened this issue 3 years ago • 1 comments

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 avatar Apr 25 '22 17:04 hhoppe

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

hhoppe avatar Apr 26 '22 23:04 hhoppe