summaryrefslogtreecommitdiffstats
path: root/Utilities/Sphinx/cmake.py
diff options
context:
space:
mode:
authorMatthew Woehlke <matthew.woehlke@kitware.com>2023-06-13 15:25:14 (GMT)
committerMatthew Woehlke <matthew.woehlke@kitware.com>2023-06-13 15:25:14 (GMT)
commit4bd1beded48dfa5150f13ed81df15035bce000d3 (patch)
tree4fc98fbba2e7eaab2c43c14efcbd2f121f62d01f /Utilities/Sphinx/cmake.py
parentcb5b148335af1466fcc9412c5fff0b4e6dbe8ebd (diff)
downloadCMake-4bd1beded48dfa5150f13ed81df15035bce000d3.zip
CMake-4bd1beded48dfa5150f13ed81df15035bce000d3.tar.gz
CMake-4bd1beded48dfa5150f13ed81df15035bce000d3.tar.bz2
Utilities/Sphinx: Don't ignore flake8 E402
Refactor commit 1f39a3cd1a (Utilities/Sphinx: Restore explicit check for Sphinx 2.x or later) to avoid needing to suppress flake8 E402. While ignoring it with respect to the docutils/sphinx imports and the sphinx version check was correct, the need to disable it for the whole file was suboptimal.
Diffstat (limited to 'Utilities/Sphinx/cmake.py')
-rw-r--r--Utilities/Sphinx/cmake.py36
1 files changed, 18 insertions, 18 deletions
diff --git a/Utilities/Sphinx/cmake.py b/Utilities/Sphinx/cmake.py
index d3eb948..e6c2266 100644
--- a/Utilities/Sphinx/cmake.py
+++ b/Utilities/Sphinx/cmake.py
@@ -11,24 +11,24 @@ from typing import Any, List, Tuple, Type, cast
import sphinx
-# Require at least Sphinx 2.x.
-# flake8 issues E402 for imports after this, but the purpose of this
-# check is to fail more clearly if the imports below will fail.
-assert sphinx.version_info >= (2,)
-
-from docutils.utils.code_analyzer import Lexer, LexerError
-from docutils.parsers.rst import Directive, directives
-from docutils.transforms import Transform
-from docutils.nodes import Element, Node, TextElement, system_message
-from docutils import io, nodes
-
-from sphinx.directives import ObjectDescription, nl_escape_re
-from sphinx.domains import Domain, ObjType
-from sphinx.roles import XRefRole
-from sphinx.util.docutils import ReferenceRole
-from sphinx.util.nodes import make_refnode
-from sphinx.util import logging, ws_re
-from sphinx import addnodes
+# The following imports may fail if we don't have Sphinx 2.x or later.
+if sphinx.version_info >= (2,):
+ from docutils.utils.code_analyzer import Lexer, LexerError
+ from docutils.parsers.rst import Directive, directives
+ from docutils.transforms import Transform
+ from docutils.nodes import Element, Node, TextElement, system_message
+ from docutils import io, nodes
+
+ from sphinx.directives import ObjectDescription, nl_escape_re
+ from sphinx.domains import Domain, ObjType
+ from sphinx.roles import XRefRole
+ from sphinx.util.docutils import ReferenceRole
+ from sphinx.util.nodes import make_refnode
+ from sphinx.util import logging, ws_re
+ from sphinx import addnodes
+else:
+ # Sphinx 2.x is required.
+ assert sphinx.version_info >= (2,)
# END imports