@@ -95,6 +95,11 @@ class C(builtins.object)
9595 | say_no(self)
9696 |\x20 \x20
9797 | ----------------------------------------------------------------------
98+ | Class methods defined here:
99+ |\x20 \x20
100+ | __class_getitem__(item) from builtins.type
101+ |\x20 \x20
102+ | ----------------------------------------------------------------------
98103 | Data descriptors defined here:
99104 |\x20 \x20
100105 | __dict__
@@ -114,6 +119,10 @@ class C(builtins.object)
114119
115120DATA
116121 __xyz__ = 'X, Y and Z'
122+ c_alias = test.pydoc_mod.C[int]
123+ list_alias1 = typing.List[int]
124+ list_alias2 = list[int]
125+ type_union1 = typing.Union[int, str]
117126
118127VERSION
119128 1.2.3.4
@@ -141,6 +150,15 @@ class C(builtins.object)
141150 <p><tt>This is a test module for test_pydoc</tt></p>
142151<p>
143152<table width="100%%" cellspacing=0 cellpadding=2 border=0 summary="section">
153+ <tr bgcolor="#aa55cc">
154+ <td colspan=3 valign=bottom> <br>
155+ <font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
156+ \x20 \x20 \x20 \x20
157+ <tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td>
158+ <td width="100%%"><table width="100%%" summary="list"><tr><td width="25%%" valign=top><a href="types.html">types</a><br>
159+ </td><td width="25%%" valign=top><a href="typing.html">typing</a><br>
160+ </td><td width="25%%" valign=top></td><td width="25%%" valign=top></td></tr></table></td></tr></table><p>
161+ <table width="100%%" cellspacing=0 cellpadding=2 border=0 summary="section">
144162<tr bgcolor="#ee77aa">
145163<td colspan=3 valign=bottom> <br>
146164<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
@@ -210,6 +228,10 @@ class C(builtins.object)
210228
211229<dl><dt><a name="C-say_no"><strong>say_no</strong></a>(self)</dt></dl>
212230
231+ <hr>
232+ Class methods defined here:<br>
233+ <dl><dt><a name="C-__class_getitem__"><strong>__class_getitem__</strong></a>(item)<font color="#909090"><font face="helvetica, arial"> from <a href="builtins.html#type">builtins.type</a></font></font></dt></dl>
234+
213235<hr>
214236Data descriptors defined here:<br>
215237<dl><dt><strong>__dict__</strong></dt>
@@ -237,7 +259,11 @@ class C(builtins.object)
237259<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
238260\x20 \x20 \x20 \x20
239261<tr><td bgcolor="#55aa55"><tt> </tt></td><td> </td>
240- <td width="100%%"><strong>__xyz__</strong> = 'X, Y and Z'</td></tr></table><p>
262+ <td width="100%%"><strong>__xyz__</strong> = 'X, Y and Z'<br>
263+ <strong>c_alias</strong> = test.pydoc_mod.C[int]<br>
264+ <strong>list_alias1</strong> = typing.List[int]<br>
265+ <strong>list_alias2</strong> = list[int]<br>
266+ <strong>type_union1</strong> = typing.Union[int, str]</td></tr></table><p>
241267<table width="100%%" cellspacing=0 cellpadding=2 border=0 summary="section">
242268<tr bgcolor="#7799ee">
243269<td colspan=3 valign=bottom> <br>
@@ -1048,6 +1074,37 @@ class C: "New-style class"
10481074 expected = 'C in module %s object' % __name__
10491075 self .assertIn (expected , pydoc .render_doc (c ))
10501076
1077+ def test_generic_alias (self ):
1078+ self .assertEqual (pydoc .describe (typing .List [int ]), '_GenericAlias' )
1079+ doc = pydoc .render_doc (typing .List [int ], renderer = pydoc .plaintext )
1080+ self .assertIn ('_GenericAlias in module typing' , doc )
1081+ self .assertIn ('\n class list(object)' , doc )
1082+ self .assertIn (list .__doc__ .strip ().splitlines ()[0 ], doc )
1083+
1084+ self .assertEqual (pydoc .describe (list [int ]), 'GenericAlias' )
1085+ doc = pydoc .render_doc (list [int ], renderer = pydoc .plaintext )
1086+ self .assertIn ('GenericAlias in module builtins' , doc )
1087+ self .assertIn ('\n class list(object)' , doc )
1088+ self .assertIn (list .__doc__ .strip ().splitlines ()[0 ], doc )
1089+
1090+ def test_union_type (self ):
1091+ self .assertEqual (pydoc .describe (typing .Union [int , str ]), '_UnionGenericAlias' )
1092+ doc = pydoc .render_doc (typing .Union [int , str ], renderer = pydoc .plaintext )
1093+ self .assertIn ('_UnionGenericAlias in module typing' , doc )
1094+ self .assertIn ('\n typing.Union' , doc )
1095+ if typing .Union .__doc__ :
1096+ self .assertIn (typing .Union .__doc__ .strip ().splitlines ()[0 ], doc )
1097+
1098+ def test_special_form (self ):
1099+ self .assertEqual (pydoc .describe (typing .Any ), '_SpecialForm' )
1100+ doc = pydoc .render_doc (typing .Any , renderer = pydoc .plaintext )
1101+ self .assertIn ('_SpecialForm in module typing' , doc )
1102+ if typing .Any .__doc__ :
1103+ self .assertIn ('\n typing.Any' , doc )
1104+ self .assertIn (typing .Any .__doc__ .strip ().splitlines ()[0 ], doc )
1105+ else :
1106+ self .assertIn ('\n class _SpecialForm(_Final)' , doc )
1107+
10511108 def test_typing_pydoc (self ):
10521109 def foo (data : typing .List [typing .Any ],
10531110 x : int ) -> typing .Iterator [typing .Tuple [int , typing .Any ]]:
0 commit comments