Skip to content

ForwardRef not unwrapped for inner quoted types in arguments #327

Open
@Terrance

Description

@Terrance

Expected behavior

ForwardRef wrappers to be removed from argument type annotations, as per 8702f62.

Actual behavior

For arguments, the wrapper is removed only if the entire type is quoted. When a quoted reference forms part of a larger type (e.g. Optional["MyClass"]), the wrapper persists in the formatted annotation.

Return types are however correctly parsed in either style.

Example

from typing import Optional

def all_quoted(arg: "Optional[MyClass]") -> "Optional[MyClass]":
    pass

def min_quoted(arg: Optional["MyClass"]) -> Optional["MyClass"]:
    pass

This produces the following, with ForwardRef wrapping the argument to min_quoted but not its return type:

Functions

all_quoted(arg: Optional[MyClass]) ‑> Optional[MyClass]

min_quoted(arg: Optional[ForwardRef('MyClass')]) ‑> Optional[MyClass]

Additional info

  • pdoc version: 0.9.2

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