@@ -70,7 +70,6 @@ class or function within a module or module in a package. If the
7070import sysconfig
7171import time
7272import tokenize
73- import types
7473import urllib .parse
7574import warnings
7675from collections import deque
@@ -92,24 +91,21 @@ def pathdirs():
9291 normdirs .append (normdir )
9392 return dirs
9493
95- def _isclass (object ):
96- return inspect .isclass (object ) and not isinstance (object , types .GenericAlias )
97-
9894def _findclass (func ):
9995 cls = sys .modules .get (func .__module__ )
10096 if cls is None :
10197 return None
10298 for name in func .__qualname__ .split ('.' )[:- 1 ]:
10399 cls = getattr (cls , name )
104- if not _isclass (cls ):
100+ if not inspect . isclass (cls ):
105101 return None
106102 return cls
107103
108104def _finddoc (obj ):
109105 if inspect .ismethod (obj ):
110106 name = obj .__func__ .__name__
111107 self = obj .__self__
112- if (_isclass (self ) and
108+ if (inspect . isclass (self ) and
113109 getattr (getattr (self , name , None ), '__func__' ) is obj .__func__ ):
114110 # classmethod
115111 cls = self
@@ -123,7 +119,7 @@ def _finddoc(obj):
123119 elif inspect .isbuiltin (obj ):
124120 name = obj .__name__
125121 self = obj .__self__
126- if (_isclass (self ) and
122+ if (inspect . isclass (self ) and
127123 self .__qualname__ + '.' + name == obj .__qualname__ ):
128124 # classmethod
129125 cls = self
@@ -210,7 +206,7 @@ def classname(object, modname):
210206
211207def isdata (object ):
212208 """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
214210 inspect .isroutine (object ) or inspect .isframe (object ) or
215211 inspect .istraceback (object ) or inspect .iscode (object ))
216212
@@ -481,7 +477,7 @@ def document(self, object, name=None, *args):
481477 # by lacking a __name__ attribute) and an instance.
482478 try :
483479 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 )
485481 if inspect .isroutine (object ): return self .docroutine (* args )
486482 except AttributeError :
487483 pass
@@ -783,7 +779,7 @@ def docmodule(self, object, name=None, mod=None, *ignored):
783779 modules = inspect .getmembers (object , inspect .ismodule )
784780
785781 classes , cdict = [], {}
786- for key , value in inspect .getmembers (object , _isclass ):
782+ for key , value in inspect .getmembers (object , inspect . isclass ):
787783 # if __all__ exists, believe it. Otherwise use old heuristic.
788784 if (all is not None or
789785 (inspect .getmodule (value ) or object ) is object ):
@@ -1223,7 +1219,7 @@ def docmodule(self, object, name=None, mod=None):
12231219 result = result + self .section ('DESCRIPTION' , desc )
12241220
12251221 classes = []
1226- for key , value in inspect .getmembers (object , _isclass ):
1222+ for key , value in inspect .getmembers (object , inspect . isclass ):
12271223 # if __all__ exists, believe it. Otherwise use old heuristic.
12281224 if (all is not None
12291225 or (inspect .getmodule (value ) or object ) is object ):
@@ -1707,7 +1703,7 @@ def describe(thing):
17071703 return 'member descriptor %s.%s.%s' % (
17081704 thing .__objclass__ .__module__ , thing .__objclass__ .__name__ ,
17091705 thing .__name__ )
1710- if _isclass (thing ):
1706+ if inspect . isclass (thing ):
17111707 return 'class ' + thing .__name__
17121708 if inspect .isfunction (thing ):
17131709 return 'function ' + thing .__name__
@@ -1768,7 +1764,7 @@ def render_doc(thing, title='Python Library Documentation: %s', forceload=0,
17681764 desc += ' in module ' + module .__name__
17691765
17701766 if not (inspect .ismodule (object ) or
1771- _isclass (object ) or
1767+ inspect . isclass (object ) or
17721768 inspect .isroutine (object ) or
17731769 inspect .isdatadescriptor (object ) or
17741770 _getdoc (object )):
0 commit comments