summaryrefslogtreecommitdiffstats
path: root/Lib/typing.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2020-04-18 14:13:21 (GMT)
committerGitHub <noreply@github.com>2020-04-18 14:13:21 (GMT)
commit7e64414f57b70dc5bc0ab19a3162a0735f9bfabf (patch)
tree89751f89c42a08b7335098b470ba6ddc395b184c /Lib/typing.py
parentc606624af8d4cb3b4a052fb263bb983b3f87585b (diff)
downloadcpython-7e64414f57b70dc5bc0ab19a3162a0735f9bfabf.zip
cpython-7e64414f57b70dc5bc0ab19a3162a0735f9bfabf.tar.gz
cpython-7e64414f57b70dc5bc0ab19a3162a0735f9bfabf.tar.bz2
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.
Diffstat (limited to 'Lib/typing.py')
-rw-r--r--Lib/typing.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/typing.py b/Lib/typing.py
index 9cacaa8..df36500 100644
--- a/Lib/typing.py
+++ b/Lib/typing.py
@@ -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):