mirror of
https://github.com/python/cpython.git
synced 2025-07-26 20:54:39 +00:00
[3.10] bpo-40296: Fix supporting generic aliases in pydoc (GH-30253). (GH-31976)
(cherry picked from commit cd44afc573
)
This commit is contained in:
parent
6fd9737373
commit
a5b7678a67
4 changed files with 92 additions and 10 deletions
|
@ -1,5 +1,8 @@
|
|||
"""This is a test module for test_pydoc"""
|
||||
|
||||
import types
|
||||
import typing
|
||||
|
||||
__author__ = "Benjamin Peterson"
|
||||
__credits__ = "Nobody"
|
||||
__version__ = "1.2.3.4"
|
||||
|
@ -24,6 +27,8 @@ class C(object):
|
|||
def is_it_true(self):
|
||||
""" Return self.get_answer() """
|
||||
return self.get_answer()
|
||||
def __class_getitem__(self, item):
|
||||
return types.GenericAlias(self, item)
|
||||
|
||||
def doc_func():
|
||||
"""
|
||||
|
@ -35,3 +40,10 @@ def doc_func():
|
|||
|
||||
def nodoc_func():
|
||||
pass
|
||||
|
||||
|
||||
list_alias1 = typing.List[int]
|
||||
list_alias2 = list[int]
|
||||
c_alias = C[int]
|
||||
type_union1 = typing.Union[int, str]
|
||||
type_union2 = int | str
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue