Skip to content

Commit 19dfc3f

Browse files
committed
Enable the RUF031 lint in Ruff
1 parent d796a8a commit 19dfc3f

File tree

7 files changed

+28
-28
lines changed

7 files changed

+28
-28
lines changed

.ruff.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ select = [
246246
"RUF028", # This suppression comment is invalid because {}
247247
"RUF029", # Function `{name}` is declared `async`, but doesn't `await` or use `async` features.
248248
"RUF030", # `print()` expression in `assert` statement is likely unintentional
249-
# "RUF031", # Use parentheses for tuples in subscripts.
249+
"RUF031", # Use parentheses for tuples in subscripts.
250250
"RUF032", # `Decimal()` called with float literal argument
251251
"RUF033", # `__post_init__` method with argument defaults
252252
"RUF034", # Useless if-else condition

sphinx/builders/latex/transforms.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ def visit_footnote_reference(self, node: nodes.footnote_reference) -> None:
455455
number = node.astext().strip()
456456
docname = node['docname']
457457
if (docname, number) in self.appeared:
458-
footnote = self.appeared[(docname, number)]
458+
footnote = self.appeared[docname, number]
459459
footnote['referred'] = True
460460

461461
mark = footnotemark('', number, refid=node['refid'])
@@ -471,7 +471,7 @@ def visit_footnote_reference(self, node: nodes.footnote_reference) -> None:
471471
node.replace_self(footnote)
472472
footnote.walkabout(self)
473473

474-
self.appeared[(docname, number)] = footnote
474+
self.appeared[docname, number] = footnote
475475
raise nodes.SkipNode
476476

477477
def get_footnote_by_reference(

sphinx/pycode/parser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,13 +283,13 @@ def add_variable_comment(self, name: str, comment: str) -> None:
283283
qualname = self.get_qualname_for(name)
284284
if qualname:
285285
basename = '.'.join(qualname[:-1])
286-
self.comments[(basename, name)] = comment
286+
self.comments[basename, name] = comment
287287

288288
def add_variable_annotation(self, name: str, annotation: ast.AST) -> None:
289289
qualname = self.get_qualname_for(name)
290290
if qualname:
291291
basename = '.'.join(qualname[:-1])
292-
self.annotations[(basename, name)] = ast_unparse(annotation)
292+
self.annotations[basename, name] = ast_unparse(annotation)
293293

294294
def is_final(self, decorators: list[ast.expr]) -> bool:
295295
final = []

sphinx/writers/latex.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,8 @@ def add_cell(self, height: int, width: int) -> None:
215215
self.cell_id += 1
216216
for col in range(width):
217217
for row in range(height):
218-
assert self.cells[(self.row + row, self.col + col)] == 0
219-
self.cells[(self.row + row, self.col + col)] = self.cell_id
218+
assert self.cells[self.row + row, self.col + col] == 0
219+
self.cells[self.row + row, self.col + col] = self.cell_id
220220

221221
def cell(
222222
self,
@@ -242,33 +242,33 @@ class TableCell:
242242
"""Data of a cell in a table."""
243243

244244
def __init__(self, table: Table, row: int, col: int) -> None:
245-
if table.cells[(row, col)] == 0:
245+
if table.cells[row, col] == 0:
246246
raise IndexError
247247

248248
self.table = table
249-
self.cell_id = table.cells[(row, col)]
249+
self.cell_id = table.cells[row, col]
250250
self.row = row
251251
self.col = col
252252

253253
# adjust position for multirow/multicol cell
254-
while table.cells[(self.row - 1, self.col)] == self.cell_id:
254+
while table.cells[self.row - 1, self.col] == self.cell_id:
255255
self.row -= 1
256-
while table.cells[(self.row, self.col - 1)] == self.cell_id:
256+
while table.cells[self.row, self.col - 1] == self.cell_id:
257257
self.col -= 1
258258

259259
@property
260260
def width(self) -> int:
261261
"""Returns the cell width."""
262262
width = 0
263-
while self.table.cells[(self.row, self.col + width)] == self.cell_id:
263+
while self.table.cells[self.row, self.col + width] == self.cell_id:
264264
width += 1
265265
return width
266266

267267
@property
268268
def height(self) -> int:
269269
"""Returns the cell height."""
270270
height = 0
271-
while self.table.cells[(self.row + height, self.col)] == self.cell_id:
271+
while self.table.cells[self.row + height, self.col] == self.cell_id:
272272
height += 1
273273
return height
274274

tests/test_domains/test_domain_std.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ def test_cmdoption(app):
414414
entries=[('pair', 'ls command line option; -l', 'cmdoption-ls-l', '', None)],
415415
)
416416
assert ('ls', '-l') in domain.progoptions
417-
assert domain.progoptions[('ls', '-l')] == ('index', 'cmdoption-ls-l')
417+
assert domain.progoptions['ls', '-l'] == ('index', 'cmdoption-ls-l')
418418

419419

420420
@pytest.mark.sphinx('html', testroot='root')
@@ -441,7 +441,7 @@ def test_cmdoption_for_None(app):
441441
entries=[('pair', 'command line option; -l', 'cmdoption-l', '', None)],
442442
)
443443
assert (None, '-l') in domain.progoptions
444-
assert domain.progoptions[(None, '-l')] == ('index', 'cmdoption-l')
444+
assert domain.progoptions[None, '-l'] == ('index', 'cmdoption-l')
445445

446446

447447
@pytest.mark.sphinx('html', testroot='root')
@@ -481,8 +481,8 @@ def test_multiple_cmdoptions(app):
481481
)
482482
assert ('cmd', '-o') in domain.progoptions
483483
assert ('cmd', '--output') in domain.progoptions
484-
assert domain.progoptions[('cmd', '-o')] == ('index', 'cmdoption-cmd-o')
485-
assert domain.progoptions[('cmd', '--output')] == ('index', 'cmdoption-cmd-o')
484+
assert domain.progoptions['cmd', '-o'] == ('index', 'cmdoption-cmd-o')
485+
assert domain.progoptions['cmd', '--output'] == ('index', 'cmdoption-cmd-o')
486486

487487

488488
@pytest.mark.sphinx('html', testroot='productionlist')

tests/test_extensions/test_ext_doctest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def test_skipif(app):
122122

123123

124124
def record(directive, part, should_skip):
125-
recorded_calls[(directive, part, should_skip)] += 1
125+
recorded_calls[directive, part, should_skip] += 1
126126
return f'Recorded {directive} {part} {should_skip}'
127127

128128

tests/test_pycode/test_pycode.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -151,15 +151,15 @@ def test_ModuleAnalyzer_find_attr_docs():
151151
('Foo', 'attr8'),
152152
('Foo', 'attr9'),
153153
}
154-
assert docs[('Foo', 'attr1')] == ['comment before attr1', '']
155-
assert docs[('Foo', 'attr3')] == ['attribute comment for attr3', '']
156-
assert docs[('Foo', 'attr4')] == ['long attribute comment', '']
157-
assert docs[('Foo', 'attr4')] == ['long attribute comment', '']
158-
assert docs[('Foo', 'attr5')] == ['attribute comment for attr5', '']
159-
assert docs[('Foo', 'attr6')] == ['this comment is ignored', '']
160-
assert docs[('Foo', 'attr7')] == ['this comment is ignored', '']
161-
assert docs[('Foo', 'attr8')] == ['attribute comment for attr8', '']
162-
assert docs[('Foo', 'attr9')] == ['string after attr9', '']
154+
assert docs['Foo', 'attr1'] == ['comment before attr1', '']
155+
assert docs['Foo', 'attr3'] == ['attribute comment for attr3', '']
156+
assert docs['Foo', 'attr4'] == ['long attribute comment', '']
157+
assert docs['Foo', 'attr4'] == ['long attribute comment', '']
158+
assert docs['Foo', 'attr5'] == ['attribute comment for attr5', '']
159+
assert docs['Foo', 'attr6'] == ['this comment is ignored', '']
160+
assert docs['Foo', 'attr7'] == ['this comment is ignored', '']
161+
assert docs['Foo', 'attr8'] == ['attribute comment for attr8', '']
162+
assert docs['Foo', 'attr9'] == ['string after attr9', '']
163163
assert analyzer.tagorder == {
164164
'Foo': 0,
165165
'Foo.__init__': 8,
@@ -189,5 +189,5 @@ def test_ModuleAnalyzer_find_attr_docs_for_posonlyargs_method():
189189
analyzer = ModuleAnalyzer.for_string(code, 'module')
190190
docs = analyzer.find_attr_docs()
191191
assert set(docs) == {('Foo', 'attr')}
192-
assert docs[('Foo', 'attr')] == ['attribute comment', '']
192+
assert docs['Foo', 'attr'] == ['attribute comment', '']
193193
assert analyzer.tagorder == {'Foo': 0, 'Foo.__init__': 1, 'Foo.attr': 2}

0 commit comments

Comments
 (0)