mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Enable the RUF015 lint in Ruff
This commit is contained in:
parent
439bff92c7
commit
2f1cd36798
@ -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
|
||||
|
@ -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))
|
||||
|
@ -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']
|
||||
|
@ -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():
|
||||
|
Loading…
Reference in New Issue
Block a user