Enable the FURB113 rule in Ruff (#11856)

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: danieleades <33452915+danieleades@users.noreply.github.com>
This commit is contained in:
Dimitri Papadopoulos Orfanos 2024-01-21 21:25:05 +01:00 committed by GitHub
parent f9c8943889
commit 4f08cdff13
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 26 additions and 30 deletions

View File

@ -135,7 +135,7 @@ select = [
# refurb ('FURB')
# "FURB101", # `open` and `read` should be replaced by `Path({filename}).{suggestion}`
# "FURB105", # Unnecessary empty string passed to `print`
# "FURB113", # Use `{suggestion}` instead of repeatedly calling `{name}.append()`
"FURB113", # Use `{suggestion}` instead of repeatedly calling `{name}.append()`
"FURB118", # Use `operator.{operator}` instead of defining a function
"FURB131", # Prefer `clear` over deleting a full slice
"FURB132", # Use `{suggestion}` instead of check and `remove`
@ -477,6 +477,8 @@ select = [
"doc/development/tutorials/examples/*" = ["INP001"]
# allow print() in the tutorial
"doc/development/tutorials/examples/recipe.py" = ["T201"]
"sphinx/domains/**" = ["FURB113"]
"tests/test_domains/test_domain_cpp.py" = ["FURB113"]
# from .flake8
"sphinx/*" = ["E241"]

View File

@ -107,8 +107,10 @@ def process_todo_nodes(app, doctree, fromdocname):
para += nodes.Text('.)')
# Insert into the todolist
content.append(todo_info['todo'])
content.append(para)
content.extend((
todo_info['todo'],
para,
))
node.replace_self(content)

View File

@ -375,9 +375,11 @@ class LaTeXBuilder(Builder):
newnodes: list[Node] = [nodes.emphasis(sectname, sectname)]
for subdir, title in self.titles:
if docname.startswith(subdir):
newnodes.append(nodes.Text(_(' (in ')))
newnodes.append(nodes.emphasis(title, title))
newnodes.append(nodes.Text(')'))
newnodes.extend((
nodes.Text(_(' (in ')),
nodes.emphasis(title, title),
nodes.Text(')'),
))
break
else:
pass

View File

@ -166,9 +166,11 @@ class TexinfoBuilder(Builder):
newnodes: list[Node] = [nodes.emphasis(sectname, sectname)]
for subdir, title in self.titles:
if docname.startswith(subdir):
newnodes.append(nodes.Text(_(' (in ')))
newnodes.append(nodes.emphasis(title, title))
newnodes.append(nodes.Text(')'))
newnodes.extend((
nodes.Text(_(' (in ')),
nodes.emphasis(title, title),
nodes.Text(')'),
))
break
else:
pass

View File

@ -307,9 +307,10 @@ class InheritanceGraph:
n_attrs.update(env.config.inheritance_node_attrs)
e_attrs.update(env.config.inheritance_edge_attrs)
res: list[str] = []
res.append('digraph %s {\n' % name)
res.append(self._format_graph_attrs(g_attrs))
res: list[str] = [
f'digraph {name} {{\n',
self._format_graph_attrs(g_attrs),
]
for name, fullname, bases, tooltip in sorted(self.class_info):
# Write the node

View File

@ -295,8 +295,7 @@ class EmphasizedLiteral(SphinxRole):
stack[-1] += "{"
else:
# start emphasis
stack.append('{')
stack.append('')
stack.extend(('{', ''))
elif part == '}':
if len(stack) == 3 and stack[1] == "{" and len(stack[2]) > 0:
# emphasized word found

View File

@ -418,17 +418,8 @@ class DefaultSplitter(BaseSplitter):
return []
result = []
seg = ['B3', 'B2', 'B1']
ctype = ['O', 'O', 'O']
for t in input:
seg.append(t)
ctype.append(self.ctype_(t))
seg.append('E1')
seg.append('E2')
seg.append('E3')
ctype.append('O')
ctype.append('O')
ctype.append('O')
seg = ['B3', 'B2', 'B1', *input, 'E1', 'E2', 'E3']
ctype = ['O', 'O', 'O', *map(self.ctype_, input), 'O', 'O', 'O']
word = seg[3]
p1 = 'U'
p2 = 'U'

View File

@ -277,14 +277,11 @@ class BaseParser:
for e in errors:
if len(e[1]) > 0:
indent = ' '
result.append(e[1])
result.append(':\n')
result.extend((e[1], ':\n'))
for line in str(e[0]).split('\n'):
if len(line) == 0:
continue
result.append(indent)
result.append(line)
result.append('\n')
result.extend((indent, line, '\n'))
else:
result.append(str(e[0]))
return DefinitionError(''.join(result))