diff --git a/sphinx/config.py b/sphinx/config.py index f3d1f7b39..87d5313ae 100644 --- a/sphinx/config.py +++ b/sphinx/config.py @@ -18,7 +18,7 @@ from os import path, getenv from typing import Any, NamedTuple, Union from six import ( - PY2, PY3, iteritems, string_types, binary_type, text_type, integer_types, class_types + PY2, PY3, iteritems, string_types, binary_type, text_type, integer_types ) from sphinx.deprecation import RemovedInSphinx30Warning @@ -38,7 +38,7 @@ if False: logger = logging.getLogger(__name__) CONFIG_FILENAME = 'conf.py' -UNSERIALIZABLE_TYPES = class_types + (types.ModuleType, types.FunctionType) +UNSERIALIZABLE_TYPES = (type, types.ModuleType, types.FunctionType) copyright_year_re = re.compile(r'^((\d{4}-)?)(\d{4})(?=[ ,])') if PY3: diff --git a/sphinx/ext/autodoc/__init__.py b/sphinx/ext/autodoc/__init__.py index 4a1cb15ce..529d644ec 100644 --- a/sphinx/ext/autodoc/__init__.py +++ b/sphinx/ext/autodoc/__init__.py @@ -18,7 +18,7 @@ import warnings from typing import Any from docutils.statemachine import ViewList -from six import iteritems, itervalues, text_type, class_types, string_types +from six import iteritems, itervalues, text_type, string_types import sphinx from sphinx.deprecation import RemovedInSphinx30Warning @@ -1061,7 +1061,7 @@ class ClassDocumenter(DocstringSignatureMixin, ModuleLevelDocumenter): # type: @classmethod def can_document_member(cls, member, membername, isattr, parent): # type: (Any, unicode, bool, Any) -> bool - return isinstance(member, class_types) + return isinstance(member, type) def import_object(self): # type: () -> Any @@ -1213,8 +1213,7 @@ class ExceptionDocumenter(ClassDocumenter): @classmethod def can_document_member(cls, member, membername, isattr, parent): # type: (Any, unicode, bool, Any) -> bool - return isinstance(member, class_types) and \ - issubclass(member, BaseException) # type: ignore + return isinstance(member, type) and issubclass(member, BaseException) class DataDocumenter(ModuleLevelDocumenter): @@ -1345,7 +1344,7 @@ class AttributeDocumenter(DocstringStripSignatureMixin, ClassLevelDocumenter): # exported anywhere by Python return isdatadesc or (not isinstance(parent, ModuleDocumenter) and not inspect.isroutine(member) and - not isinstance(member, class_types)) + not isinstance(member, type)) def document_members(self, all_members=False): # type: (bool) -> None