Skip to content

"x | y" does not work but "Union[x, y]" does #441

@AnthonyZJiang

Description

@AnthonyZJiang

e.g. for a method:

def get_val() -> int | str:
    """Get value.

    Returns:
        int | str: the value.
    """
    pass

Expected Behavior

def get_val() ‑> int | str
Get value.

Returns
int | str
The value.

Actual Behavior

def get_val() ‑> int | str
Get value.

Returns
int | None The value.

See more details in the attached picture

Steps to Reproduce

Additional info

  • pdoc version: 0.10.0

Example 1

Here is the example in action, comparing | and Union:
image

Example 2

Here's another example of using | instead of Union:
image

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

    Issue actions