Skip to content

Commit

Permalink
Enable the FURB113 lint in Ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
AA-Turner committed Jan 3, 2025
1 parent ff26932 commit b176c66
Show file tree
Hide file tree
Showing 9 changed files with 246 additions and 208 deletions.
3 changes: 0 additions & 3 deletions .ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,6 @@ select = [
"PLW3201", # Dunder method {name} has no special meaning in Python 3
]

"sphinx/domains/**" = ["FURB113"]
"tests/test_domains/test_domain_cpp.py" = ["FURB113"]

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

Expand Down
50 changes: 27 additions & 23 deletions sphinx/domains/c/_ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,9 +625,11 @@ def __hash__(self) -> int:

def _stringify(self, transform: StringifyTransform) -> str:
res = ['(']
res.append(transform(self.typ))
res.append(')')
res.append(transform(self.expr))
res.extend((
transform(self.typ),
')',
transform(self.expr),
))
return ''.join(res)

def describe_signature(
Expand Down Expand Up @@ -658,10 +660,12 @@ def _stringify(self, transform: StringifyTransform) -> str:
res = []
res.append(transform(self.exprs[0]))
for i in range(1, len(self.exprs)):
res.append(' ')
res.append(self.ops[i - 1])
res.append(' ')
res.append(transform(self.exprs[i]))
res.extend((
' ',
self.ops[i - 1],
' ',
transform(self.exprs[i]),
))
return ''.join(res)

def describe_signature(
Expand Down Expand Up @@ -698,10 +702,12 @@ def _stringify(self, transform: StringifyTransform) -> str:
res = []
res.append(transform(self.exprs[0]))
for i in range(1, len(self.exprs)):
res.append(' ')
res.append(self.ops[i - 1])
res.append(' ')
res.append(transform(self.exprs[i]))
res.extend((
' ',
self.ops[i - 1],
' ',
transform(self.exprs[i]),
))
return ''.join(res)

def describe_signature(
Expand Down Expand Up @@ -798,10 +804,9 @@ def name(self) -> ASTNestedName:
return self.nestedName

def _stringify(self, transform: StringifyTransform) -> str:
res = []
res: list[str] = []
if self.prefix:
res.append(self.prefix)
res.append(' ')
res.extend((self.prefix, ' '))
res.append(transform(self.nestedName))
return ''.join(res)

Expand Down Expand Up @@ -877,8 +882,7 @@ def _stringify(self, transform: StringifyTransform) -> str:
res.append(str(a))
res.append(')')
if len(self.attrs) != 0:
res.append(' ')
res.append(transform(self.attrs))
res.extend((' ', transform(self.attrs)))
return ''.join(res)

def describe_signature(
Expand Down Expand Up @@ -1278,8 +1282,7 @@ def _stringify(self, transform: StringifyTransform) -> str:
res = []
if self.declId:
res.append(transform(self.declId))
res.append(' : ')
res.append(transform(self.size))
res.extend((' : ', transform(self.size)))
return ''.join(res)

def describe_signature(
Expand Down Expand Up @@ -1419,9 +1422,11 @@ def require_space_after_declSpecs(self) -> bool:

def _stringify(self, transform: StringifyTransform) -> str:
res = ['(']
res.append(transform(self.inner))
res.append(')')
res.append(transform(self.next))
res.extend((
transform(self.inner),
')',
transform(self.next),
))
return ''.join(res)

def describe_signature(
Expand Down Expand Up @@ -1824,8 +1829,7 @@ def _stringify(self, transform: StringifyTransform) -> str:
res = []
res.append(transform(self.name))
if len(self.attrs) != 0:
res.append(' ')
res.append(transform(self.attrs))
res.extend((' ', transform(self.attrs)))
if self.init:
res.append(transform(self.init))
return ''.join(res)
Expand Down
14 changes: 8 additions & 6 deletions sphinx/domains/c/_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,10 @@ def _parse_cast_expression(self) -> ASTExpression:
try:
return self._parse_unary_expression()
except DefinitionError as ex_unary:
errs = []
errs.append((ex_cast, 'If type cast expression'))
errs.append((ex_unary, 'If unary expression'))
errs = [
(ex_cast, 'If type cast expression'),
(ex_unary, 'If unary expression'),
]
raise self._make_multi_error(
errs, 'Error in cast expression.'
) from ex_unary
Expand Down Expand Up @@ -1111,8 +1112,9 @@ def parse_expression(self) -> ASTExpression | ASTType:
self.assert_end()
except DefinitionError as ex_type:
header = 'Error when parsing (type) expression.'
errs = []
errs.append((ex_expr, 'If expression'))
errs.append((ex_type, 'If type'))
errs = [
(ex_expr, 'If expression'),
(ex_type, 'If type'),
]
raise self._make_multi_error(errs, header) from ex_type
return res
8 changes: 5 additions & 3 deletions sphinx/domains/c/_symbol.py
Original file line number Diff line number Diff line change
Expand Up @@ -692,9 +692,11 @@ def to_string(self, indent: int, *, addEndNewline: bool = True) -> str:
res.append('!!duplicate!! ')
res.append(str(self.declaration))
if self.docname:
res.append('\t(')
res.append(self.docname)
res.append(')')
res.extend((
'\t(',
self.docname,
')',
))
if addEndNewline:
res.append('\n')
return ''.join(res)
Expand Down
Loading

0 comments on commit b176c66

Please sign in to comment.