Skip to content

TypeVars of generic classes not shown, duplicate ancestors/subclasses listed  #117

@Terrance

Description

@Terrance

Expected Behavior

  • Generic classes, in usage and in definition, should include TypeVar parameters.

Actual Behavior

  • TypeVar parameters are omitted from usage.
  • TypeVar parameters are shown on definition, but only as part of the constructor (though this is the most common case).
  • typing.Generic is listed as an ancestor twice.
  • The class is listed as a subclass of itself once per reference that completes the generic.

Steps to Reproduce

Sample code
from typing import Generic, TypeVar

T = TypeVar("T")

class Foo(Generic[T]):
    """A generic class."""

    def __init__(self, x: T):
        self.x = x

def a() -> Foo[int]:
    return Foo(1)

def b() -> Foo[str]:
    return Foo("b")

def c() -> Foo[bool]:
    return Foo(True)

def d() -> Foo:
    return Foo(None)
Build and output
$ pdoc3 --html --config show_type_annotations=True --config show_source_code=False test

image

Foo is listed as a subclass three times, for each of a, b, c (as d doesn't define T).

Additional info

  • pdoc version: 0.7.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingupstreamIssue affects a dependency of ourswontfixThis will not be worked on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions