Use `# NoQA` consistently (#11903)

Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
This commit is contained in:
danieleades 2024-01-21 20:20:58 +00:00 committed by GitHub
parent 95b2cce9a0
commit f9c8943889
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
24 changed files with 33 additions and 33 deletions

View File

@ -189,7 +189,7 @@ nitpick_ignore = {
# -- Extension interface -------------------------------------------------------
from sphinx import addnodes # noqa: E402
from sphinx import addnodes # NoQA: E402
event_sig_re = re.compile(r'([a-zA-Z-]+)\s*\((.*)\)')

View File

@ -25,8 +25,8 @@ from sphinx.util.osutil import SEP, ensuredir, relative_uri, relpath
from sphinx.util.parallel import ParallelTasks, SerialTasks, make_chunks, parallel_available
# side effect: registers roles and directives
from sphinx import directives # noqa: F401 isort:skip
from sphinx import roles # noqa: F401 isort:skip
from sphinx import directives # NoQA: F401 isort:skip
from sphinx import roles # NoQA: F401 isort:skip
if TYPE_CHECKING:
from collections.abc import Iterable, Sequence

View File

@ -1338,7 +1338,7 @@ def setup(app: Sphinx) -> dict[str, Any]:
app.add_config_value('html_search_scorer', '', '')
app.add_config_value('html_scaled_image_link', True, 'html')
app.add_config_value('html_baseurl', '', 'html')
app.add_config_value('html_codeblock_linenos_style', 'inline', 'html', # RemovedInSphinx70Warning # noqa: E501
app.add_config_value('html_codeblock_linenos_style', 'inline', 'html', # RemovedInSphinx70Warning # NoQA: E501
ENUM('table', 'inline'))
app.add_config_value('html_math_renderer', None, 'env')
app.add_config_value('html4_writer', False, 'html')

View File

@ -9,7 +9,7 @@ from typing import TYPE_CHECKING, Any
from docutils.frontend import OptionParser
import sphinx.builders.latex.nodes # noqa: F401,E501 # Workaround: import this before writer to avoid ImportError
import sphinx.builders.latex.nodes # NoQA: F401,E501 # Workaround: import this before writer to avoid ImportError
from sphinx import addnodes, highlighting, package_dir
from sphinx.builders import Builder
from sphinx.builders.latex.constants import ADDITIONAL_SETTINGS, DEFAULT_SETTINGS, SHORTHANDOFF

View File

@ -408,7 +408,7 @@ class HyperlinkAvailabilityCheckWorker(Thread):
req_url = encode_uri(req_url)
# Get auth info, if any
for pattern, auth_info in self.auth: # noqa: B007 (false positive)
for pattern, auth_info in self.auth: # NoQA: B007 (false positive)
if pattern.match(uri):
break
else:

View File

@ -245,9 +245,9 @@ def ask_user(d: dict[str, Any]) -> None:
if 'dot' not in d:
print()
print(__('Inside the root directory, two more directories will be created; "_templates"\n' # noqa: E501
'for custom HTML templates and "_static" for custom stylesheets and other static\n' # noqa: E501
'files. You can enter another prefix (such as ".") to replace the underscore.')) # noqa: E501
print(__('Inside the root directory, two more directories will be created; "_templates"\n' # NoQA: E501
'for custom HTML templates and "_static" for custom stylesheets and other static\n' # NoQA: E501
'files. You can enter another prefix (such as ".") to replace the underscore.')) # NoQA: E501
d['dot'] = do_prompt(__('Name prefix for templates and static dir'), '_', ok)
if 'project' not in d:

View File

@ -13,7 +13,7 @@ from docutils.parsers.rst.directives.misc import Include as BaseInclude
from docutils.statemachine import StateMachine
from sphinx import addnodes
from sphinx.domains.changeset import VersionChange # noqa: F401 # for compatibility
from sphinx.domains.changeset import VersionChange # NoQA: F401 # for compatibility
from sphinx.domains.std import StandardDomain
from sphinx.locale import _, __
from sphinx.util import docname_join, logging, url_re

View File

@ -627,7 +627,7 @@ class CDomain(Domain):
'enumerator': ObjType(_('enumerator'), 'enumerator', 'identifier'),
'type': ObjType(_('type'), 'identifier', 'type'),
# generated object types
'functionParam': ObjType(_('function parameter'), 'identifier', 'var', 'member', 'data'), # noqa: E501
'functionParam': ObjType(_('function parameter'), 'identifier', 'var', 'member', 'data'), # NoQA: E501
}
directives = {

View File

@ -758,9 +758,9 @@ class CPPDomain(Domain):
'enum': ObjType(_('enum'), 'enum', 'identifier', 'type'),
'enumerator': ObjType(_('enumerator'), 'enumerator', 'identifier'),
# generated object types
'functionParam': ObjType(_('function parameter'), 'identifier', 'member', 'var'), # noqa: E501
'functionParam': ObjType(_('function parameter'), 'identifier', 'member', 'var'), # NoQA: E501
'templateParam': ObjType(_('template parameter'),
'identifier', 'class', 'struct', 'union', 'member', 'var', 'type'), # noqa: E501
'identifier', 'class', 'struct', 'union', 'member', 'var', 'type'), # NoQA: E501
}
directives = {

View File

@ -46,7 +46,7 @@ class MetadataCollector(EnvironmentCollector):
md[field_name.astext()] = field_body.astext()
elif isinstance(node, nodes.TextElement):
# other children must be TextElement
# see: https://docutils.sourceforge.io/docs/ref/doctree.html#bibliographic-elements # noqa: E501
# see: https://docutils.sourceforge.io/docs/ref/doctree.html#bibliographic-elements # NoQA: E501
md[node.__class__.__name__] = node.astext()
for name, value in md.items():

View File

@ -70,7 +70,7 @@ def read_svg_depth(filename: str) -> int | None:
"""Read the depth from comment at last line of SVG file
"""
with open(filename, encoding="utf-8") as f:
for line in f: # noqa: B007
for line in f: # NoQA: B007
pass
# Only last line is checked
matched = depthsvgcomment_re.match(line)

View File

@ -539,7 +539,7 @@ class GoogleDocstring:
return [(' ' * n) + line for line in lines]
def _is_indented(self, line: str, indent: int = 1) -> bool:
for i, s in enumerate(line): # noqa: SIM110
for i, s in enumerate(line): # NoQA: SIM110
if i >= indent:
return True
elif not s.isspace():

View File

@ -70,7 +70,7 @@ def _slice_index(values: list, slices: int) -> Iterator[list]:
count = 0
start = offset
if slices == slice_number + 1: # last column
offset = len(seq) # noqa: SIM113
offset = len(seq) # NoQA: SIM113
else:
for value in values[offset:]:
count += 1 + len(value[1][1])

View File

@ -200,7 +200,7 @@ def get_translation(catalog: str, namespace: str = 'general') -> Callable[[str],
def gettext(message: str) -> str:
if not is_translator_registered(catalog, namespace):
# not initialized yet
return _TranslationProxy(catalog, namespace, message) # type: ignore[return-value] # noqa: E501
return _TranslationProxy(catalog, namespace, message) # type: ignore[return-value] # NoQA: E501
else:
translator = get_translator(catalog, namespace)
return translator.gettext(message)

View File

@ -20,8 +20,8 @@ from sphinx.util import index_entries as _index_entries
from sphinx.util import logging
from sphinx.util import osutil as _osutil
from sphinx.util.console import strip_colors # NoQA: F401
from sphinx.util.matching import patfilter # noqa: F401
from sphinx.util.nodes import ( # noqa: F401
from sphinx.util.matching import patfilter # NoQA: F401
from sphinx.util.nodes import ( # NoQA: F401
caption_ref_re,
explicit_title_re,
nested_parse_with_titles,
@ -30,7 +30,7 @@ from sphinx.util.nodes import ( # noqa: F401
# import other utilities; partly for backwards compatibility, so don't
# prune unused ones indiscriminately
from sphinx.util.osutil import ( # noqa: F401
from sphinx.util.osutil import ( # NoQA: F401
SEP,
copyfile,
copytimes,

View File

@ -385,7 +385,7 @@ def switch_source_input(state: State, content: StringList) -> Generator[None, No
# replace it by new one
state_machine = StateMachine([], None) # type: ignore[arg-type]
state_machine.input_lines = content
state.memo.reporter.get_source_and_line = state_machine.get_source_and_line # type: ignore[attr-defined] # noqa: E501
state.memo.reporter.get_source_and_line = state_machine.get_source_and_line # type: ignore[attr-defined] # NoQA: E501
yield
finally:

View File

@ -14,7 +14,7 @@ import typing
from collections.abc import Mapping, Sequence
from functools import cached_property, partial, partialmethod, singledispatchmethod
from importlib import import_module
from inspect import ( # noqa: F401
from inspect import ( # NoQA: F401
Parameter,
isasyncgenfunction,
isclass,

View File

@ -2261,6 +2261,6 @@ class LaTeXTranslator(SphinxTranslator):
# FIXME: Workaround to avoid circular import
# refs: https://github.com/sphinx-doc/sphinx/issues/5433
from sphinx.builders.latex.nodes import ( # noqa: E402 # isort:skip
from sphinx.builders.latex.nodes import ( # NoQA: E402 # isort:skip
HYPERLINK_SUPPORT_NODES, captioned_literal_block, footnotetext,
)

View File

@ -8,9 +8,9 @@ from sphinx.transforms.post_transforms.images import ImageConverter
if False:
# For type annotation
from typing import Any, Dict # NOQA
from typing import Any, Dict # NoQA
from sphinx.application import Sphinx # NOQA
from sphinx.application import Sphinx # NoQA
class MyConverter(ImageConverter):
conversion_rules = [

View File

@ -749,7 +749,7 @@ def test_domain_c_build_intersphinx(tmp_path, app, status, warning):
.. c:type:: _type
.. c:function:: void _functionParam(int param)
""" # noqa: F841
""" # NoQA: F841
inv_file = tmp_path / 'inventory'
inv_file.write_bytes(b'''\
# Sphinx inventory version 2
@ -769,7 +769,7 @@ _struct c:struct 1 index.html#c.$ -
_type c:type 1 index.html#c.$ -
_union c:union 1 index.html#c.$ -
_var c:member 1 index.html#c.$ -
''')) # noqa: W291
''')) # NoQA: W291
app.config.intersphinx_mapping = {
'https://localhost/intersphinx/c/': str(inv_file),
}

View File

@ -1397,7 +1397,7 @@ def test_domain_cpp_build_intersphinx(tmp_path, app, status, warning):
.. cpp:enum-class:: _enumClass
.. cpp:function:: void _functionParam(int param)
.. cpp:function:: template<typename TParam> void _templateParam()
""" # noqa: F841
""" # NoQA: F841
inv_file = tmp_path / 'inventory'
inv_file.write_bytes(b'''\
# Sphinx inventory version 2
@ -1424,7 +1424,7 @@ _templateParam::TParam cpp:templateParam 1 index.html#_CPPv4I0E14_templateParamv
_type cpp:type 1 index.html#_CPPv45$ -
_union cpp:union 1 index.html#_CPPv46$ -
_var cpp:member 1 index.html#_CPPv44$ -
''')) # noqa: W291
''')) # NoQA: W291
app.config.intersphinx_mapping = {
'https://localhost/intersphinx/cpp/': str(inv_file),
}

View File

@ -1157,7 +1157,7 @@ Methods:
description
""" # noqa: W293
""" # NoQA: W293
config = Config()
actual = str(GoogleDocstring(docstring, config=config, app=None, what='module',
options={'no-index': True}))

View File

@ -853,7 +853,7 @@ def test_getdoc_inherited_decorated_method():
"""
class Bar(Foo):
@functools.lru_cache # noqa: B019
@functools.lru_cache # NoQA: B019
def meth(self):
# inherited and decorated method
pass

View File

@ -77,7 +77,7 @@ def f14() -> Any:
pass
def f15(x: "Unknown", y: "int") -> Any: # noqa: F821 # type: ignore[attr-defined]
def f15(x: "Unknown", y: "int") -> Any: # NoQA: F821 # type: ignore[attr-defined]
pass