mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
simplify some set comparisons (SIM109)
This commit is contained in:
parent
e79681c768
commit
e51591d061
@ -703,7 +703,7 @@ class EpubBuilder(StandaloneHTMLBuilder):
|
||||
epub_filename = path.join(self.outdir, outname)
|
||||
with ZipFile(epub_filename, 'w', ZIP_DEFLATED) as epub:
|
||||
epub.write(path.join(self.outdir, 'mimetype'), 'mimetype', ZIP_STORED)
|
||||
for filename in ['META-INF/container.xml', 'content.opf', 'toc.ncx']:
|
||||
for filename in ('META-INF/container.xml', 'content.opf', 'toc.ncx'):
|
||||
epub.write(path.join(self.outdir, filename), filename, ZIP_DEFLATED)
|
||||
for filename in self.files:
|
||||
epub.write(path.join(self.outdir, filename), filename, ZIP_DEFLATED)
|
||||
|
@ -148,7 +148,7 @@ class ChangesBuilder(Builder):
|
||||
|
||||
def hl(self, text: str, version: str) -> str:
|
||||
text = html.escape(text)
|
||||
for directive in ['versionchanged', 'versionadded', 'deprecated']:
|
||||
for directive in ('versionchanged', 'versionadded', 'deprecated'):
|
||||
text = text.replace('.. %s:: %s' % (directive, version),
|
||||
'<b>.. %s:: %s</b>' % (directive, version))
|
||||
return text
|
||||
|
@ -217,7 +217,7 @@ class ASTNestedName(ASTBase):
|
||||
assert not self.rooted, str(self)
|
||||
assert len(self.names) == 1
|
||||
self.names[0].describe_signature(signode, 'noneIsName', env, '', symbol)
|
||||
elif mode == 'markType' or mode == 'lastIsName' or mode == 'markName':
|
||||
elif mode in ('markType', 'lastIsName', 'markName'):
|
||||
# Each element should be a pending xref targeting the complete
|
||||
# prefix.
|
||||
prefix = ''
|
||||
|
@ -776,7 +776,7 @@ class ASTNestedName(ASTBase):
|
||||
assert len(self.names) == 1
|
||||
assert not self.templates[0]
|
||||
self.names[0].describe_signature(signode, 'param', env, '', symbol)
|
||||
elif mode == 'markType' or mode == 'lastIsName' or mode == 'markName':
|
||||
elif mode in ('markType', 'lastIsName', 'markName'):
|
||||
# Each element should be a pending xref targeting the complete
|
||||
# prefix. however, only the identifier part should be a link, such
|
||||
# that template args can be a link as well.
|
||||
@ -5385,7 +5385,7 @@ class DefinitionParser(BaseParser):
|
||||
postFixes: List[ASTPostfixOp] = []
|
||||
while True:
|
||||
self.skip_ws()
|
||||
if prefixType in ['expr', 'cast', 'typeid']:
|
||||
if prefixType in ('expr', 'cast', 'typeid'):
|
||||
if self.skip_string_and_ws('['):
|
||||
expr = self._parse_expression()
|
||||
self.skip_ws()
|
||||
@ -7781,7 +7781,7 @@ class CPPDomain(Domain):
|
||||
typ: str, target: str, node: pending_xref,
|
||||
contnode: Element) -> Tuple[Optional[Element], Optional[str]]:
|
||||
# add parens again for those that could be functions
|
||||
if typ == 'any' or typ == 'func':
|
||||
if typ in ('any', 'func'):
|
||||
target += '()'
|
||||
parser = DefinitionParser(target, location=node, config=env.config)
|
||||
try:
|
||||
@ -7902,7 +7902,7 @@ class CPPDomain(Domain):
|
||||
if (env.config.add_function_parentheses and typ == 'func' and
|
||||
title.endswith('operator()')):
|
||||
addParen += 1
|
||||
if ((typ == 'any' or typ == 'func') and
|
||||
if (typ in ('any', 'func') and
|
||||
title.endswith('operator') and
|
||||
displayName.endswith('operator()')):
|
||||
addParen += 1
|
||||
|
@ -444,10 +444,10 @@ def _skip_member(app: Sphinx, what: str, name: str, obj: Any,
|
||||
|
||||
"""
|
||||
has_doc = getattr(obj, '__doc__', False)
|
||||
is_member = (what == 'class' or what == 'exception' or what == 'module')
|
||||
is_member = what in ('class', 'exception', 'module')
|
||||
if name != '__weakref__' and has_doc and is_member:
|
||||
cls_is_owner = False
|
||||
if what == 'class' or what == 'exception':
|
||||
if what in ('class', 'exception'):
|
||||
qualname = getattr(obj, '__qualname__', '')
|
||||
cls_path, _, _ = qualname.rpartition('.')
|
||||
if cls_path:
|
||||
|
@ -375,12 +375,8 @@ def is_suppressed_warning(type: str, subtype: str, suppress_warnings: List[str])
|
||||
else:
|
||||
target, subtarget = warning_type, None
|
||||
|
||||
if target == type:
|
||||
if ((subtype is None and subtarget is None) or
|
||||
subtarget is None or
|
||||
subtarget == subtype or
|
||||
subtarget == '*'):
|
||||
return True
|
||||
if target == type and subtarget in (None, subtype, "*"):
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
|
@ -123,7 +123,7 @@ class PorterStemmer:
|
||||
or not self.cons(i - 2):
|
||||
return 0
|
||||
ch = self.b[i]
|
||||
if ch == 'w' or ch == 'x' or ch == 'y':
|
||||
if ch in ('w', 'x', 'y'):
|
||||
return 0
|
||||
return 1
|
||||
|
||||
@ -193,7 +193,7 @@ class PorterStemmer:
|
||||
elif self.doublec(self.k):
|
||||
self.k = self.k - 1
|
||||
ch = self.b[self.k]
|
||||
if ch == 'l' or ch == 's' or ch == 'z':
|
||||
if ch in ('l', 's', 'z'):
|
||||
self.k = self.k + 1
|
||||
elif (self.m() == 1 and self.cvc(self.k)):
|
||||
self.setto("e")
|
||||
|
Loading…
Reference in New Issue
Block a user