@@ -95,6 +95,11 @@ class C(builtins.object)
95
95
| say_no(self)
96
96
|\x20 \x20
97
97
| ----------------------------------------------------------------------
98
+ | Class methods defined here:
99
+ |\x20 \x20
100
+ | __class_getitem__(item) from builtins.type
101
+ |\x20 \x20
102
+ | ----------------------------------------------------------------------
98
103
| Data descriptors defined here:
99
104
|\x20 \x20
100
105
| __dict__
@@ -114,6 +119,10 @@ class C(builtins.object)
114
119
115
120
DATA
116
121
__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]
117
126
118
127
VERSION
119
128
1.2.3.4
@@ -141,6 +150,15 @@ class C(builtins.object)
141
150
<p><tt>This is a test module for test_pydoc</tt></p>
142
151
<p>
143
152
<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">
144
162
<tr bgcolor="#ee77aa">
145
163
<td colspan=3 valign=bottom> <br>
146
164
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
@@ -210,6 +228,10 @@ class C(builtins.object)
210
228
211
229
<dl><dt><a name="C-say_no"><strong>say_no</strong></a>(self)</dt></dl>
212
230
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
+
213
235
<hr>
214
236
Data descriptors defined here:<br>
215
237
<dl><dt><strong>__dict__</strong></dt>
@@ -237,7 +259,11 @@ class C(builtins.object)
237
259
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
238
260
\x20 \x20 \x20 \x20
239
261
<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>
241
267
<table width="100%%" cellspacing=0 cellpadding=2 border=0 summary="section">
242
268
<tr bgcolor="#7799ee">
243
269
<td colspan=3 valign=bottom> <br>
@@ -1048,6 +1074,37 @@ class C: "New-style class"
1048
1074
expected = 'C in module %s object' % __name__
1049
1075
self .assertIn (expected , pydoc .render_doc (c ))
1050
1076
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
+
1051
1108
def test_typing_pydoc (self ):
1052
1109
def foo (data : typing .List [typing .Any ],
1053
1110
x : int ) -> typing .Iterator [typing .Tuple [int , typing .Any ]]:
0 commit comments