Issue 28519: Update pydoc tool to support generic types (original) (raw)

It was proposed in the discussion of #27989 to update pydoc rendering of documentation of classes supporting generic types.

Currently there are two ideas:

  1. Keep the class header intact (i.e. listing actual runtime bases) and adding a separate section describing generic info using orig_bases and parameters. For example:

""" class MyClass(typing.List, typing.Mapping): ... (usual info) ... This is a generic class consistent with List[~T], Mapping[str, +VT_co] Type parameters: invariant T, covariant VT_co """

  1. Do not add a separate section, but modify the header to display orig_bases. For example:

""" class MyClass(List[~T], Mapping[str, +VT_co]): ... (usual info) ...

"""

Guido prefers the second option. I am a bit afraid that this will cause people to use issubclass() with parameterized generics, but now issubclass(cls, List[T]) is a TypeError, only issubclass(cls, List) is allowed. So that I am more inclined towards first option.