Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Lib/pydoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1672,8 +1672,11 @@ def render_doc(thing, title='Python Library Documentation: %s', forceload=0,
inspect.getdoc(object)):
# If the passed object is a piece of data or an instance,
# document its available methods instead of its value.
object = type(object)
desc += ' object'
if hasattr(object, '__origin__'):
object = object.__origin__
else:
object = type(object)
desc += ' object'
return title % desc + '\n\n' + renderer.document(object, name)

def doc(thing, title='Python Library Documentation: %s', forceload=0,
Expand Down
10 changes: 10 additions & 0 deletions Lib/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,14 @@ def __init__(self, name, doc):
self._name = name
self._doc = doc

@property
def __doc__(self):
return self._doc

@__doc__.setter
def __doc__(self, value):
self._doc = value
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this to be settable? If possible I would keep it read-only, but it is not very important.


def __eq__(self, other):
if not isinstance(other, _SpecialForm):
return NotImplemented
Expand Down Expand Up @@ -672,6 +680,8 @@ def __init__(self, origin, params, *, inst=True, special=False, name=None):
self.__slots__ = None # This is not documented.
if not name:
self.__module__ = origin.__module__
if special:
self.__doc__ = f'A generic version of {origin.__module__}.{origin.__qualname__}'

@_tp_cache
def __getitem__(self, params):
Expand Down