Skip to content

Commit 4f08cdf

Browse files
DimitriPapadopoulosAA-Turnerdanieleades
authored
Enable the FURB113 rule in Ruff (sphinx-doc#11856)
Co-authored-by: Adam Turner <[email protected]> Co-authored-by: danieleades <[email protected]>
1 parent f9c8943 commit 4f08cdf

File tree

8 files changed

+26
-30
lines changed

8 files changed

+26
-30
lines changed

.ruff.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ select = [
135135
# refurb ('FURB')
136136
# "FURB101", # `open` and `read` should be replaced by `Path({filename}).{suggestion}`
137137
# "FURB105", # Unnecessary empty string passed to `print`
138-
# "FURB113", # Use `{suggestion}` instead of repeatedly calling `{name}.append()`
138+
"FURB113", # Use `{suggestion}` instead of repeatedly calling `{name}.append()`
139139
"FURB118", # Use `operator.{operator}` instead of defining a function
140140
"FURB131", # Prefer `clear` over deleting a full slice
141141
"FURB132", # Use `{suggestion}` instead of check and `remove`
@@ -477,6 +477,8 @@ select = [
477477
"doc/development/tutorials/examples/*" = ["INP001"]
478478
# allow print() in the tutorial
479479
"doc/development/tutorials/examples/recipe.py" = ["T201"]
480+
"sphinx/domains/**" = ["FURB113"]
481+
"tests/test_domains/test_domain_cpp.py" = ["FURB113"]
480482

481483
# from .flake8
482484
"sphinx/*" = ["E241"]

doc/development/tutorials/examples/todo.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,10 @@ def process_todo_nodes(app, doctree, fromdocname):
107107
para += nodes.Text('.)')
108108

109109
# Insert into the todolist
110-
content.append(todo_info['todo'])
111-
content.append(para)
110+
content.extend((
111+
todo_info['todo'],
112+
para,
113+
))
112114

113115
node.replace_self(content)
114116

sphinx/builders/latex/__init__.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -375,9 +375,11 @@ def assemble_doctree(
375375
newnodes: list[Node] = [nodes.emphasis(sectname, sectname)]
376376
for subdir, title in self.titles:
377377
if docname.startswith(subdir):
378-
newnodes.append(nodes.Text(_(' (in ')))
379-
newnodes.append(nodes.emphasis(title, title))
380-
newnodes.append(nodes.Text(')'))
378+
newnodes.extend((
379+
nodes.Text(_(' (in ')),
380+
nodes.emphasis(title, title),
381+
nodes.Text(')'),
382+
))
381383
break
382384
else:
383385
pass

sphinx/builders/texinfo.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,11 @@ def assemble_doctree(
166166
newnodes: list[Node] = [nodes.emphasis(sectname, sectname)]
167167
for subdir, title in self.titles:
168168
if docname.startswith(subdir):
169-
newnodes.append(nodes.Text(_(' (in ')))
170-
newnodes.append(nodes.emphasis(title, title))
171-
newnodes.append(nodes.Text(')'))
169+
newnodes.extend((
170+
nodes.Text(_(' (in ')),
171+
nodes.emphasis(title, title),
172+
nodes.Text(')'),
173+
))
172174
break
173175
else:
174176
pass

sphinx/ext/inheritance_diagram.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,9 +307,10 @@ def generate_dot(self, name: str, urls: dict[str, str] | None = None,
307307
n_attrs.update(env.config.inheritance_node_attrs)
308308
e_attrs.update(env.config.inheritance_edge_attrs)
309309

310-
res: list[str] = []
311-
res.append('digraph %s {\n' % name)
312-
res.append(self._format_graph_attrs(g_attrs))
310+
res: list[str] = [
311+
f'digraph {name} {{\n',
312+
self._format_graph_attrs(g_attrs),
313+
]
313314

314315
for name, fullname, bases, tooltip in sorted(self.class_info):
315316
# Write the node

sphinx/roles.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,7 @@ def parse(self, text: str) -> list[Node]:
295295
stack[-1] += "{"
296296
else:
297297
# start emphasis
298-
stack.append('{')
299-
stack.append('')
298+
stack.extend(('{', ''))
300299
elif part == '}':
301300
if len(stack) == 3 and stack[1] == "{" and len(stack[2]) > 0:
302301
# emphasized word found

sphinx/search/ja.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -418,17 +418,8 @@ def split(self, input: str) -> list[str]:
418418
return []
419419

420420
result = []
421-
seg = ['B3', 'B2', 'B1']
422-
ctype = ['O', 'O', 'O']
423-
for t in input:
424-
seg.append(t)
425-
ctype.append(self.ctype_(t))
426-
seg.append('E1')
427-
seg.append('E2')
428-
seg.append('E3')
429-
ctype.append('O')
430-
ctype.append('O')
431-
ctype.append('O')
421+
seg = ['B3', 'B2', 'B1', *input, 'E1', 'E2', 'E3']
422+
ctype = ['O', 'O', 'O', *map(self.ctype_, input), 'O', 'O', 'O']
432423
word = seg[3]
433424
p1 = 'U'
434425
p2 = 'U'

sphinx/util/cfamily.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -277,14 +277,11 @@ def _make_multi_error(self, errors: list[Any], header: str) -> DefinitionError:
277277
for e in errors:
278278
if len(e[1]) > 0:
279279
indent = ' '
280-
result.append(e[1])
281-
result.append(':\n')
280+
result.extend((e[1], ':\n'))
282281
for line in str(e[0]).split('\n'):
283282
if len(line) == 0:
284283
continue
285-
result.append(indent)
286-
result.append(line)
287-
result.append('\n')
284+
result.extend((indent, line, '\n'))
288285
else:
289286
result.append(str(e[0]))
290287
return DefinitionError(''.join(result))

0 commit comments

Comments
 (0)