@@ -70,7 +70,6 @@ class or function within a module or module in a package. If the
70
70
import sysconfig
71
71
import time
72
72
import tokenize
73
- import types
74
73
import urllib .parse
75
74
import warnings
76
75
from collections import deque
@@ -92,24 +91,21 @@ def pathdirs():
92
91
normdirs .append (normdir )
93
92
return dirs
94
93
95
- def _isclass (object ):
96
- return inspect .isclass (object ) and not isinstance (object , types .GenericAlias )
97
-
98
94
def _findclass (func ):
99
95
cls = sys .modules .get (func .__module__ )
100
96
if cls is None :
101
97
return None
102
98
for name in func .__qualname__ .split ('.' )[:- 1 ]:
103
99
cls = getattr (cls , name )
104
- if not _isclass (cls ):
100
+ if not inspect . isclass (cls ):
105
101
return None
106
102
return cls
107
103
108
104
def _finddoc (obj ):
109
105
if inspect .ismethod (obj ):
110
106
name = obj .__func__ .__name__
111
107
self = obj .__self__
112
- if (_isclass (self ) and
108
+ if (inspect . isclass (self ) and
113
109
getattr (getattr (self , name , None ), '__func__' ) is obj .__func__ ):
114
110
# classmethod
115
111
cls = self
@@ -123,7 +119,7 @@ def _finddoc(obj):
123
119
elif inspect .isbuiltin (obj ):
124
120
name = obj .__name__
125
121
self = obj .__self__
126
- if (_isclass (self ) and
122
+ if (inspect . isclass (self ) and
127
123
self .__qualname__ + '.' + name == obj .__qualname__ ):
128
124
# classmethod
129
125
cls = self
@@ -210,7 +206,7 @@ def classname(object, modname):
210
206
211
207
def isdata (object ):
212
208
"""Check if an object is of a type that probably means it's data."""
213
- return not (inspect .ismodule (object ) or _isclass (object ) or
209
+ return not (inspect .ismodule (object ) or inspect . isclass (object ) or
214
210
inspect .isroutine (object ) or inspect .isframe (object ) or
215
211
inspect .istraceback (object ) or inspect .iscode (object ))
216
212
@@ -481,7 +477,7 @@ def document(self, object, name=None, *args):
481
477
# by lacking a __name__ attribute) and an instance.
482
478
try :
483
479
if inspect .ismodule (object ): return self .docmodule (* args )
484
- if _isclass (object ): return self .docclass (* args )
480
+ if inspect . isclass (object ): return self .docclass (* args )
485
481
if inspect .isroutine (object ): return self .docroutine (* args )
486
482
except AttributeError :
487
483
pass
@@ -783,7 +779,7 @@ def docmodule(self, object, name=None, mod=None, *ignored):
783
779
modules = inspect .getmembers (object , inspect .ismodule )
784
780
785
781
classes , cdict = [], {}
786
- for key , value in inspect .getmembers (object , _isclass ):
782
+ for key , value in inspect .getmembers (object , inspect . isclass ):
787
783
# if __all__ exists, believe it. Otherwise use old heuristic.
788
784
if (all is not None or
789
785
(inspect .getmodule (value ) or object ) is object ):
@@ -1223,7 +1219,7 @@ def docmodule(self, object, name=None, mod=None):
1223
1219
result = result + self .section ('DESCRIPTION' , desc )
1224
1220
1225
1221
classes = []
1226
- for key , value in inspect .getmembers (object , _isclass ):
1222
+ for key , value in inspect .getmembers (object , inspect . isclass ):
1227
1223
# if __all__ exists, believe it. Otherwise use old heuristic.
1228
1224
if (all is not None
1229
1225
or (inspect .getmodule (value ) or object ) is object ):
@@ -1707,7 +1703,7 @@ def describe(thing):
1707
1703
return 'member descriptor %s.%s.%s' % (
1708
1704
thing .__objclass__ .__module__ , thing .__objclass__ .__name__ ,
1709
1705
thing .__name__ )
1710
- if _isclass (thing ):
1706
+ if inspect . isclass (thing ):
1711
1707
return 'class ' + thing .__name__
1712
1708
if inspect .isfunction (thing ):
1713
1709
return 'function ' + thing .__name__
@@ -1768,7 +1764,7 @@ def render_doc(thing, title='Python Library Documentation: %s', forceload=0,
1768
1764
desc += ' in module ' + module .__name__
1769
1765
1770
1766
if not (inspect .ismodule (object ) or
1771
- _isclass (object ) or
1767
+ inspect . isclass (object ) or
1772
1768
inspect .isroutine (object ) or
1773
1769
inspect .isdatadescriptor (object ) or
1774
1770
_getdoc (object )):
0 commit comments