Skip to content

Commit

Permalink
Enable the RUF015 lint in Ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
AA-Turner committed Nov 30, 2024
1 parent 439bff9 commit 2f1cd36
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ select = [
"RUF010", # Use explicit conversion flag
# "RUF012", # Mutable class attributes should be annotated with `typing.ClassVar`
"RUF013", # PEP 484 prohibits implicit `Optional`
# "RUF015", # Prefer `next({iterable})` over single element slice
"RUF015", # Prefer `next({iterable})` over single element slice
"RUF016", # Slice in indexed access to type `{value_type}` uses type `{index_type}` instead of an integer
"RUF017", # Avoid quadratic list summation
"RUF018", # Avoid assignment expressions in `assert` statements
Expand Down
20 changes: 12 additions & 8 deletions tests/test_domains/test_domain_std.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,19 +504,23 @@ def test_productionlist(app):
ul = nodes[2]
cases = []
for li in list(ul):
assert len(list(li)) == 1
p = list(li)[0]
li_list = list(li)
assert len(li_list) == 1
p = li_list[0]
assert p.tag == 'p'
text = str(p.text).strip(' :')
assert len(list(p)) == 1
a = list(p)[0]
p_list = list(p)
assert len(p_list) == 1
a = p_list[0]
assert a.tag == 'a'
link = a.get('href')
assert len(list(a)) == 1
code = list(a)[0]
a_list = list(a)
assert len(a_list) == 1
code = a_list[0]
assert code.tag == 'code'
assert len(list(code)) == 1
span = list(code)[0]
code_list = list(code)
assert len(code_list) == 1
span = code_list[0]
assert span.tag == 'span'
linkText = span.text.strip()
cases.append((text, link, linkText))
Expand Down
2 changes: 1 addition & 1 deletion tests/test_extensions/test_ext_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def test_build(app):
)
assert len(undoc_c) == 1
# the key is the full path to the header file, which isn't testable
assert list(undoc_c.values())[0] == {('function', 'Py_SphinxTest')}
assert next(iter(undoc_c.values())) == {('function', 'Py_SphinxTest')}

assert 'autodoc_target' in undoc_py
assert 'funcs' in undoc_py['autodoc_target']
Expand Down
2 changes: 1 addition & 1 deletion tests/test_util/test_util_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def test_extract_messages_without_rawsource():
document.append(p)
_transform(document)
assert_node_count(extract_messages(document), nodes.TextElement, 1)
assert [m for n, m in extract_messages(document)][0], 'text sentence'
assert next(m for n, m in extract_messages(document)), 'text sentence'


def test_clean_astext():
Expand Down

0 comments on commit 2f1cd36

Please sign in to comment.