diff options
Diffstat (limited to 'sphinx/ext/inheritance_diagram.py')
-rw-r--r-- | sphinx/ext/inheritance_diagram.py | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/sphinx/ext/inheritance_diagram.py b/sphinx/ext/inheritance_diagram.py index 7b2383fca..63a171087 100644 --- a/sphinx/ext/inheritance_diagram.py +++ b/sphinx/ext/inheritance_diagram.py @@ -31,7 +31,7 @@ r""" The graph is inserted as a PNG+image map into HTML and a PDF in LaTeX. - :copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS. + :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS. :license: BSD, see LICENSE for details. """ @@ -39,8 +39,7 @@ import builtins import inspect import re from importlib import import_module -from typing import Any, Dict, Iterable, List, Tuple -from typing import cast +from typing import Any, Dict, Iterable, List, Tuple, cast from docutils import nodes from docutils.nodes import Node @@ -50,22 +49,23 @@ import sphinx from sphinx import addnodes from sphinx.application import Sphinx from sphinx.environment import BuildEnvironment -from sphinx.ext.graphviz import ( - graphviz, figure_wrapper, - render_dot_html, render_dot_latex, render_dot_texinfo -) +from sphinx.ext.graphviz import (figure_wrapper, graphviz, render_dot_html, render_dot_latex, + render_dot_texinfo) from sphinx.util import md5 from sphinx.util.docutils import SphinxDirective from sphinx.writers.html import HTMLTranslator from sphinx.writers.latex import LaTeXTranslator from sphinx.writers.texinfo import TexinfoTranslator - module_sig_re = re.compile(r'''^(?:([\w.]*)\.)? # module names (\w+) \s* $ # class/final module name ''', re.VERBOSE) +py_builtins = [obj for obj in vars(builtins).values() + if inspect.isclass(obj)] + + def try_import(objname: str) -> Any: """Import a object or module using *name* and *currentmodule*. *name* should be a relative name from *currentmodule* or @@ -178,7 +178,6 @@ class InheritanceGraph: traverse to. Multiple names can be specified separated by comma. """ all_classes = {} - py_builtins = vars(builtins).values() def recurse(cls: Any) -> None: if not show_builtins and cls in py_builtins: |