diff --git a/sphinx/builders/_epub_base.py b/sphinx/builders/_epub_base.py index 453687978..d17361a21 100644 --- a/sphinx/builders/_epub_base.py +++ b/sphinx/builders/_epub_base.py @@ -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) diff --git a/sphinx/builders/changes.py b/sphinx/builders/changes.py index 0086fa158..a80e53d9a 100644 --- a/sphinx/builders/changes.py +++ b/sphinx/builders/changes.py @@ -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), '.. %s:: %s' % (directive, version)) return text diff --git a/sphinx/domains/c.py b/sphinx/domains/c.py index 6ed4f1559..74556c3be 100644 --- a/sphinx/domains/c.py +++ b/sphinx/domains/c.py @@ -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 = '' diff --git a/sphinx/domains/cpp.py b/sphinx/domains/cpp.py index c8625e81d..30772c105 100644 --- a/sphinx/domains/cpp.py +++ b/sphinx/domains/cpp.py @@ -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 diff --git a/sphinx/ext/napoleon/__init__.py b/sphinx/ext/napoleon/__init__.py index 557ed7735..fab918d41 100644 --- a/sphinx/ext/napoleon/__init__.py +++ b/sphinx/ext/napoleon/__init__.py @@ -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: diff --git a/sphinx/util/logging.py b/sphinx/util/logging.py index bcf8bf63d..7294885b5 100644 --- a/sphinx/util/logging.py +++ b/sphinx/util/logging.py @@ -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 diff --git a/sphinx/util/stemmer/porter.py b/sphinx/util/stemmer/porter.py index 55e2d329d..52ca31e0c 100644 --- a/sphinx/util/stemmer/porter.py +++ b/sphinx/util/stemmer/porter.py @@ -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")