mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Apply refrub/ruff rule FURB109 (#11836)
Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
This commit is contained in:
parent
4227154cf3
commit
4303c6dd31
@ -888,7 +888,7 @@ class StandaloneHTMLBuilder(Builder):
|
|||||||
|
|
||||||
if self.config.html_scaled_image_link and self.html_scaled_image_link:
|
if self.config.html_scaled_image_link and self.html_scaled_image_link:
|
||||||
for node in doctree.findall(nodes.image):
|
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
|
# resizing options are not given. scaled image link is available
|
||||||
# only for resized images.
|
# only for resized images.
|
||||||
continue
|
continue
|
||||||
|
@ -2240,8 +2240,8 @@ class DefinitionParser(BaseParser):
|
|||||||
if self.match(float_literal_re):
|
if self.match(float_literal_re):
|
||||||
self.match(float_literal_suffix_re)
|
self.match(float_literal_suffix_re)
|
||||||
return ASTNumberLiteral(self.definition[pos:self.pos])
|
return ASTNumberLiteral(self.definition[pos:self.pos])
|
||||||
for regex in [binary_literal_re, hex_literal_re,
|
for regex in (binary_literal_re, hex_literal_re,
|
||||||
integer_literal_re, octal_literal_re]:
|
integer_literal_re, octal_literal_re):
|
||||||
if self.match(regex):
|
if self.match(regex):
|
||||||
self.match(integers_literal_suffix_re)
|
self.match(integers_literal_suffix_re)
|
||||||
return ASTNumberLiteral(self.definition[pos:self.pos])
|
return ASTNumberLiteral(self.definition[pos:self.pos])
|
||||||
|
@ -5301,8 +5301,8 @@ class DefinitionParser(BaseParser):
|
|||||||
return floatLit
|
return floatLit
|
||||||
else:
|
else:
|
||||||
return _udl(floatLit)
|
return _udl(floatLit)
|
||||||
for regex in [binary_literal_re, hex_literal_re,
|
for regex in (binary_literal_re, hex_literal_re,
|
||||||
integer_literal_re, octal_literal_re]:
|
integer_literal_re, octal_literal_re):
|
||||||
if self.match(regex):
|
if self.match(regex):
|
||||||
hasSuffix = self.match(integers_literal_suffix_re)
|
hasSuffix = self.match(integers_literal_suffix_re)
|
||||||
intLit = ASTNumberLiteral(self.definition[pos:self.pos])
|
intLit = ASTNumberLiteral(self.definition[pos:self.pos])
|
||||||
|
@ -140,7 +140,7 @@ def compile_math(latex: str, builder: Builder) -> str:
|
|||||||
# --output-directory option, so we have to manually chdir to the
|
# --output-directory option, so we have to manually chdir to the
|
||||||
# temp dir to run it.
|
# temp dir to run it.
|
||||||
command = [builder.config.imgmath_latex]
|
command = [builder.config.imgmath_latex]
|
||||||
if imgmath_latex_name not in ['tectonic']:
|
if imgmath_latex_name != 'tectonic':
|
||||||
command.append('--interaction=nonstopmode')
|
command.append('--interaction=nonstopmode')
|
||||||
# add custom args from the config file
|
# add custom args from the config file
|
||||||
command.extend(builder.config.imgmath_latex_args)
|
command.extend(builder.config.imgmath_latex_args)
|
||||||
@ -149,7 +149,7 @@ def compile_math(latex: str, builder: Builder) -> str:
|
|||||||
try:
|
try:
|
||||||
subprocess.run(command, capture_output=True, cwd=tempdir, check=True,
|
subprocess.run(command, capture_output=True, cwd=tempdir, check=True,
|
||||||
encoding='ascii')
|
encoding='ascii')
|
||||||
if imgmath_latex_name in ['xelatex', 'tectonic']:
|
if imgmath_latex_name in {'xelatex', 'tectonic'}:
|
||||||
return path.join(tempdir, 'math.xdv')
|
return path.join(tempdir, 'math.xdv')
|
||||||
else:
|
else:
|
||||||
return path.join(tempdir, 'math.dvi')
|
return path.join(tempdir, 'math.dvi')
|
||||||
|
@ -115,7 +115,7 @@ class _UnparseVisitor(ast.NodeVisitor):
|
|||||||
# Special case ``**`` to not have surrounding spaces.
|
# Special case ``**`` to not have surrounding spaces.
|
||||||
if isinstance(node.op, ast.Pow):
|
if isinstance(node.op, ast.Pow):
|
||||||
return "".join(map(self.visit, (node.left, node.op, node.right)))
|
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:
|
def visit_BoolOp(self, node: ast.BoolOp) -> str:
|
||||||
op = " %s " % self.visit(node.op)
|
op = " %s " % self.visit(node.op)
|
||||||
|
@ -220,7 +220,7 @@ def isdescriptor(x: Any) -> bool:
|
|||||||
"""Check if the object is some kind of descriptor."""
|
"""Check if the object is some kind of descriptor."""
|
||||||
return any(
|
return any(
|
||||||
callable(safe_getattr(x, item, None))
|
callable(safe_getattr(x, item, None))
|
||||||
for item in ['__get__', '__set__', '__delete__']
|
for item in ('__get__', '__set__', '__delete__')
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -2122,13 +2122,13 @@ class LaTeXTranslator(SphinxTranslator):
|
|||||||
|
|
||||||
def visit_inline(self, node: Element) -> None:
|
def visit_inline(self, node: Element) -> None:
|
||||||
classes = node.get('classes', [])
|
classes = node.get('classes', [])
|
||||||
if classes in [['menuselection']]:
|
if classes == ['menuselection']:
|
||||||
self.body.append(r'\sphinxmenuselection{')
|
self.body.append(r'\sphinxmenuselection{')
|
||||||
self.context.append('}')
|
self.context.append('}')
|
||||||
elif classes in [['guilabel']]:
|
elif classes == ['guilabel']:
|
||||||
self.body.append(r'\sphinxguilabel{')
|
self.body.append(r'\sphinxguilabel{')
|
||||||
self.context.append('}')
|
self.context.append('}')
|
||||||
elif classes in [['accelerator']]:
|
elif classes == ['accelerator']:
|
||||||
self.body.append(r'\sphinxaccelerator{')
|
self.body.append(r'\sphinxaccelerator{')
|
||||||
self.context.append('}')
|
self.context.append('}')
|
||||||
elif classes and not self.in_title:
|
elif classes and not self.in_title:
|
||||||
|
Loading…
Reference in New Issue
Block a user