1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-19 19:43:23 +08:00

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.
This commit is contained in:
Matthew Woehlke
2023-06-13 11:25:14 -04:00
parent cb5b148335
commit 4bd1beded4
2 changed files with 17 additions and 20 deletions

View File

@@ -1,3 +0,0 @@
[flake8]
per-file-ignores =
cmake.py: E402

View File

@@ -11,11 +11,8 @@ 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,)
# 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
@@ -29,6 +26,9 @@ 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