mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
bpo-40257: Improve help for the typing module (GH-19546)
* Show docstring for special forms. * Show docstring for special generic aliases. * Show documentation for __origin__ for generic aliases.
This commit is contained in:
parent
c606624af8
commit
7e64414f57
5 changed files with 24 additions and 4 deletions
|
@ -323,6 +323,10 @@ class _SpecialForm(_Final, _Immutable, _root=True):
|
|||
self._name = name
|
||||
self._doc = doc
|
||||
|
||||
@property
|
||||
def __doc__(self):
|
||||
return self._doc
|
||||
|
||||
def __eq__(self, other):
|
||||
if not isinstance(other, _SpecialForm):
|
||||
return NotImplemented
|
||||
|
@ -672,6 +676,8 @@ class _GenericAlias(_Final, _root=True):
|
|||
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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue