81 lines
2.9 KiB
Diff
81 lines
2.9 KiB
Diff
|
From 4bd1beded48dfa5150f13ed81df15035bce000d3 Mon Sep 17 00:00:00 2001
|
||
|
From: Matthew Woehlke <matthew.woehlke@kitware.com>
|
||
|
Date: Tue, 13 Jun 2023 11:25:14 -0400
|
||
|
Subject: [PATCH 6/9] Utilities/Sphinx: Don't ignore flake8 E402
|
||
|
MIME-Version: 1.0
|
||
|
Content-Type: text/plain; charset=UTF-8
|
||
|
Content-Transfer-Encoding: 8bit
|
||
|
|
||
|
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.
|
||
|
|
||
|
Signed-off-by: Björn Esser <besser82@fedoraproject.org>
|
||
|
---
|
||
|
Utilities/Sphinx/.flake8 | 3 ---
|
||
|
Utilities/Sphinx/cmake.py | 36 ++++++++++++++++++------------------
|
||
|
2 files changed, 18 insertions(+), 21 deletions(-)
|
||
|
delete mode 100644 Utilities/Sphinx/.flake8
|
||
|
|
||
|
diff --git a/Utilities/Sphinx/.flake8 b/Utilities/Sphinx/.flake8
|
||
|
deleted file mode 100644
|
||
|
index 7218008fed..0000000000
|
||
|
--- a/Utilities/Sphinx/.flake8
|
||
|
+++ /dev/null
|
||
|
@@ -1,3 +0,0 @@
|
||
|
-[flake8]
|
||
|
-per-file-ignores =
|
||
|
- cmake.py: E402
|
||
|
diff --git a/Utilities/Sphinx/cmake.py b/Utilities/Sphinx/cmake.py
|
||
|
index d3eb94814c..e6c2266938 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
|
||
|
|
||
|
--
|
||
|
2.41.0
|
||
|
|