Apply refrub/ruff rule FURB109 (#11836)

Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
This commit is contained in:
Dimitri Papadopoulos Orfanos 2024-01-04 04:12:12 +01:00 committed by GitHub
parent 4227154cf3
commit 4303c6dd31
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 12 additions and 12 deletions

View File

@ -888,7 +888,7 @@ class StandaloneHTMLBuilder(Builder):
if self.config.html_scaled_image_link and self.html_scaled_image_link:
for node in doctree.findall(nodes.image):
if not any((key in node) for key in ['scale', 'width', 'height']):
if not any((key in node) for key in ('scale', 'width', 'height')):
# resizing options are not given. scaled image link is available
# only for resized images.
continue

View File

@ -2240,8 +2240,8 @@ class DefinitionParser(BaseParser):
if self.match(float_literal_re):
self.match(float_literal_suffix_re)
return ASTNumberLiteral(self.definition[pos:self.pos])
for regex in [binary_literal_re, hex_literal_re,
integer_literal_re, octal_literal_re]:
for regex in (binary_literal_re, hex_literal_re,
integer_literal_re, octal_literal_re):
if self.match(regex):
self.match(integers_literal_suffix_re)
return ASTNumberLiteral(self.definition[pos:self.pos])

View File

@ -5301,8 +5301,8 @@ class DefinitionParser(BaseParser):
return floatLit
else:
return _udl(floatLit)
for regex in [binary_literal_re, hex_literal_re,
integer_literal_re, octal_literal_re]:
for regex in (binary_literal_re, hex_literal_re,
integer_literal_re, octal_literal_re):
if self.match(regex):
hasSuffix = self.match(integers_literal_suffix_re)
intLit = ASTNumberLiteral(self.definition[pos:self.pos])

View File

@ -140,7 +140,7 @@ def compile_math(latex: str, builder: Builder) -> str:
# --output-directory option, so we have to manually chdir to the
# temp dir to run it.
command = [builder.config.imgmath_latex]
if imgmath_latex_name not in ['tectonic']:
if imgmath_latex_name != 'tectonic':
command.append('--interaction=nonstopmode')
# add custom args from the config file
command.extend(builder.config.imgmath_latex_args)
@ -149,7 +149,7 @@ def compile_math(latex: str, builder: Builder) -> str:
try:
subprocess.run(command, capture_output=True, cwd=tempdir, check=True,
encoding='ascii')
if imgmath_latex_name in ['xelatex', 'tectonic']:
if imgmath_latex_name in {'xelatex', 'tectonic'}:
return path.join(tempdir, 'math.xdv')
else:
return path.join(tempdir, 'math.dvi')

View File

@ -115,7 +115,7 @@ class _UnparseVisitor(ast.NodeVisitor):
# Special case ``**`` to not have surrounding spaces.
if isinstance(node.op, ast.Pow):
return "".join(map(self.visit, (node.left, node.op, node.right)))
return " ".join(self.visit(e) for e in [node.left, node.op, node.right])
return " ".join(map(self.visit, (node.left, node.op, node.right)))
def visit_BoolOp(self, node: ast.BoolOp) -> str:
op = " %s " % self.visit(node.op)

View File

@ -220,7 +220,7 @@ def isdescriptor(x: Any) -> bool:
"""Check if the object is some kind of descriptor."""
return any(
callable(safe_getattr(x, item, None))
for item in ['__get__', '__set__', '__delete__']
for item in ('__get__', '__set__', '__delete__')
)

View File

@ -2122,13 +2122,13 @@ class LaTeXTranslator(SphinxTranslator):
def visit_inline(self, node: Element) -> None:
classes = node.get('classes', [])
if classes in [['menuselection']]:
if classes == ['menuselection']:
self.body.append(r'\sphinxmenuselection{')
self.context.append('}')
elif classes in [['guilabel']]:
elif classes == ['guilabel']:
self.body.append(r'\sphinxguilabel{')
self.context.append('}')
elif classes in [['accelerator']]:
elif classes == ['accelerator']:
self.body.append(r'\sphinxaccelerator{')
self.context.append('}')
elif classes and not self.in_title: