Skip to content

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

Closed
@hhoppe

Description

@hhoppe
Contributor

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

Activity

hhoppe

hhoppe commented on Apr 26, 2022

@hhoppe
ContributorAuthor

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

hhoppe commented on Nov 26, 2024

@hhoppe
ContributorAuthor

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

added a commit that references this issue on Nov 26, 2024
kernc

kernc commented on Nov 26, 2024

@kernc
Member

No options—sane defaults. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @kernc@hhoppe

        Issue actions

          Documentation shows unexpected ForwardRef(None) inside Union. · Issue #395 · pdoc3/pdoc