Enable the G003 lint in Ruff

This commit is contained in:
Adam Turner 2025-01-13 23:21:30 +00:00
parent 66905d24e1
commit 477401c4e4
11 changed files with 23 additions and 25 deletions

View File

@ -29,8 +29,6 @@ ignore = [
"E741", # Ambiguous variable name: `{name}` "E741", # Ambiguous variable name: `{name}`
# pyflakes # pyflakes
"F841", # Local variable `{name}` is assigned to but never used "F841", # Local variable `{name}` is assigned to but never used
# flake8-logging-format
"G003", # Logging statement uses `+`
# refurb # refurb
"FURB101", # `open` and `read` should be replaced by `Path(...).read_text(...)` "FURB101", # `open` and `read` should be replaced by `Path(...).read_text(...)`
"FURB103", # `open` and `write` should be replaced by `Path(...).write_text(...)` "FURB103", # `open` and `write` should be replaced by `Path(...).write_text(...)`

View File

@ -250,7 +250,7 @@ class Builder:
def cat2relpath(cat: CatalogInfo, srcdir: Path = self.srcdir) -> str: def cat2relpath(cat: CatalogInfo, srcdir: Path = self.srcdir) -> str:
return relpath(cat.mo_path, srcdir).replace(os.path.sep, SEP) return relpath(cat.mo_path, srcdir).replace(os.path.sep, SEP)
logger.info(bold(__('building [mo]: ')) + message) logger.info(bold(__('building [mo]: ')) + message) # NoQA: G003
for catalog in status_iterator( for catalog in status_iterator(
catalogs, catalogs,
__('writing output... '), __('writing output... '),
@ -390,7 +390,7 @@ class Builder:
:meth:`!write`. :meth:`!write`.
""" """
if summary: if summary:
logger.info(bold(__('building [%s]: ')) + summary, self.name) logger.info(bold(__('building [%s]: ')) + summary, self.name) # NoQA: G003
# while reading, collect all warnings from docutils # while reading, collect all warnings from docutils
with ( with (

View File

@ -364,7 +364,7 @@ class StandaloneHTMLBuilder(Builder):
msg = __( msg = __(
'build_info mismatch, copying .buildinfo to .buildinfo.bak' 'build_info mismatch, copying .buildinfo to .buildinfo.bak'
) )
logger.info(bold(__('building [html]: ')) + msg) logger.info(bold(__('building [html]: ')) + msg) # NoQA: G003
yield from self.env.found_docs yield from self.env.found_docs
return return
@ -379,7 +379,7 @@ class StandaloneHTMLBuilder(Builder):
# Let users know they have a newer template # Let users know they have a newer template
if template_mtime > old_mtime: if template_mtime > old_mtime:
logger.info( logger.info(
bold('building [html]: ') bold('building [html]: ') # NoQA: G003
+ __( + __(
'template %s has been changed since the previous build, ' 'template %s has been changed since the previous build, '
'all docs will be rebuilt' 'all docs will be rebuilt'
@ -713,7 +713,7 @@ class StandaloneHTMLBuilder(Builder):
def gen_additional_pages(self) -> None: def gen_additional_pages(self) -> None:
# additional pages from conf.py # additional pages from conf.py
for pagename, template in self.config.html_additional_pages.items(): for pagename, template in self.config.html_additional_pages.items():
logger.info(pagename + ' ', nonl=True) logger.info('%s ', pagename, nonl=True)
self.handle_page(pagename, {}, template) self.handle_page(pagename, {}, template)
# the search page # the search page

View File

@ -468,7 +468,7 @@ class LaTeXBuilder(Builder):
@progress_message(__('copying additional files')) @progress_message(__('copying additional files'))
def copy_latex_additional_files(self) -> None: def copy_latex_additional_files(self) -> None:
for filename in self.config.latex_additional_files: for filename in self.config.latex_additional_files:
logger.info(' ' + filename, nonl=True) logger.info(' %s', filename, nonl=True)
source = self.confdir / filename source = self.confdir / filename
copyfile( copyfile(
source, source,

View File

@ -123,9 +123,9 @@ class CheckExternalLinksBuilder(DummyBuilder):
msg = f'{res_uri}: {result.message}' msg = f'{res_uri}: {result.message}'
else: else:
msg = res_uri msg = res_uri
logger.info(darkgray('-ignored- ') + msg) logger.info(darkgray('-ignored- ') + msg) # NoQA: G003
case _Status.WORKING: case _Status.WORKING:
logger.info(darkgreen('ok ') + f'{res_uri}{result.message}') logger.info(darkgreen('ok ') + f'{res_uri}{result.message}') # NoQA: G003
case _Status.TIMEOUT: case _Status.TIMEOUT:
if self.app.quiet: if self.app.quiet:
msg = 'timeout ' + f'{res_uri}{result.message}' msg = 'timeout ' + f'{res_uri}{result.message}'
@ -433,7 +433,7 @@ class HyperlinkAvailabilityCheckWorker(Thread):
status, info, code = self._check(docname, uri, hyperlink) status, info, code = self._check(docname, uri, hyperlink)
if status == _Status.RATE_LIMITED: if status == _Status.RATE_LIMITED:
logger.info( logger.info(
darkgray('-rate limited- ') + uri + darkgray(' | sleeping...') darkgray('-rate limited- ') + uri + darkgray(' | sleeping...') # NoQA: G003
) )
else: else:
self.rqueue.put(CheckResult(uri, docname, lineno, status, info, code)) self.rqueue.put(CheckResult(uri, docname, lineno, status, info, code))

View File

@ -93,7 +93,7 @@ class ManualPageBuilder(Builder):
else: else:
targetname = f'{name}.{section}' targetname = f'{name}.{section}'
logger.info(darkgreen(targetname) + ' { ') logger.info('%s { ', darkgreen(targetname))
destination = FileOutput( destination = FileOutput(
destination_path=os.path.join(self.outdir, targetname), destination_path=os.path.join(self.outdir, targetname),
encoding='utf-8', encoding='utf-8',

View File

@ -195,7 +195,7 @@ class SingleFileHTMLBuilder(StandaloneHTMLBuilder):
# additional pages from conf.py # additional pages from conf.py
for pagename, template in self.config.html_additional_pages.items(): for pagename, template in self.config.html_additional_pages.items():
logger.info(' ' + pagename, nonl=True) logger.info(' %s', pagename, nonl=True)
self.handle_page(pagename, {}, template) self.handle_page(pagename, {}, template)
if self.config.html_use_opensearch: if self.config.html_use_opensearch:

View File

@ -266,7 +266,7 @@ class CoverageBuilder(Builder):
) )
else: else:
logger.info( logger.info(
red('undocumented ') red('undocumented ') # NoQA: G003
+ f'c api {f"{name} [{typ:>9}]":<30}' + f'c api {f"{name} [{typ:>9}]":<30}'
+ red(' - in file ') + red(' - in file ')
+ filename + filename
@ -459,7 +459,7 @@ class CoverageBuilder(Builder):
else: else:
for func in undoc['funcs']: for func in undoc['funcs']:
logger.info( logger.info(
red('undocumented ') red('undocumented ') # NoQA: G003
+ f'py function {func:<30}' + f'py function {func:<30}'
+ red(' - in module ') + red(' - in module ')
+ name + name
@ -479,7 +479,7 @@ class CoverageBuilder(Builder):
) )
else: else:
logger.info( logger.info(
red('undocumented ') red('undocumented ') # NoQA: G003
+ f'py class {class_name:<30}' + f'py class {class_name:<30}'
+ red(' - in module ') + red(' - in module ')
+ name + name
@ -502,7 +502,7 @@ class CoverageBuilder(Builder):
else: else:
for meth in methods: for meth in methods:
logger.info( logger.info(
red('undocumented ') red('undocumented ') # NoQA: G003
+ f'py method {f"{class_name}.{meth}":<30}' + f'py method {f"{class_name}.{meth}":<30}'
+ red(' - in module ') + red(' - in module ')
+ name + name

View File

@ -292,9 +292,9 @@ def _fetch_inventory_group(
else: else:
issues = '\n'.join(f[0] % f[1:] for f in failures) issues = '\n'.join(f[0] % f[1:] for f in failures)
LOGGER.warning( LOGGER.warning(
__('failed to reach any of the inventories with the following issues:') '%s\n%s',
+ '\n' __('failed to reach any of the inventories with the following issues:'),
+ issues issues,
) )
return updated return updated

View File

@ -40,7 +40,7 @@ def status_iterator(
if length == 0: if length == 0:
logger.info(bold_summary, nonl=True) logger.info(bold_summary, nonl=True)
for item in iterable: for item in iterable:
logger.info(stringify_func(item) + ' ', nonl=True, color=color) logger.info('%s ', stringify_func(item), nonl=True, color=color)
yield item yield item
else: else:
for i, item in enumerate(iterable, start=1): for i, item in enumerate(iterable, start=1):
@ -78,14 +78,14 @@ class progress_message:
) -> bool: ) -> bool:
prefix = '' if self.nonl else bold(self.message + ': ') prefix = '' if self.nonl else bold(self.message + ': ')
if isinstance(val, SkipProgressMessage): if isinstance(val, SkipProgressMessage):
logger.info(prefix + __('skipped')) logger.info(prefix + __('skipped')) # NoQA: G003
if val.args: if val.args:
logger.info(*val.args) logger.info(*val.args)
return True return True
elif val: elif val:
logger.info(prefix + __('failed')) logger.info(prefix + __('failed')) # NoQA: G003
else: else:
logger.info(prefix + __('done')) logger.info(prefix + __('done')) # NoQA: G003
return False return False

View File

@ -471,7 +471,7 @@ def inline_all_toctrees(
if includefile not in traversed: if includefile not in traversed:
try: try:
traversed.append(includefile) traversed.append(includefile)
logger.info(indent + colorfunc(includefile)) logger.info(indent + colorfunc(includefile)) # NoQA: G003
subtree = inline_all_toctrees( subtree = inline_all_toctrees(
builder, builder,
docnameset, docnameset,