diff --git a/bikeshed/Spec.py b/bikeshed/Spec.py index 7ce609e39f..65956526eb 100644 --- a/bikeshed/Spec.py +++ b/bikeshed/Spec.py @@ -490,7 +490,7 @@ def printTargets(self) -> None: def isOpaqueElement(self, el: t.ElementT) -> bool: if el.tag in self.md.opaqueElements: return True - if el.get("data-opaque") is not None or el.get("bs-opaque") is not None: + if el.get("data-opaque") is not None or el.get("bs-opaque") is not None: # noqa needless-bool return True return False diff --git a/bikeshed/cli.py b/bikeshed/cli.py index 464d73e501..56510a53b9 100644 --- a/bikeshed/cli.py +++ b/bikeshed/cli.py @@ -693,12 +693,12 @@ def handleProfile(options: argparse.Namespace) -> None: root = f'--root="{options.root}"' if options.root else "" leaf = f'--leaf="{options.leaf}"' if options.leaf else "" if options.svgFile: - os.system( - f"time python -m cProfile -o stat.prof -m bikeshed -f spec && gprof2dot -f pstats --skew=.0001 {root} {leaf} stat.prof | dot -Tsvg -o {options.svgFile} && rm stat.prof", # noqa: S605 + os.system( # noqa s605 + f"time python -m cProfile -o stat.prof -m bikeshed -f spec && gprof2dot -f pstats --skew=.0001 {root} {leaf} stat.prof | dot -Tsvg -o {options.svgFile} && rm stat.prof", ) else: - os.system( - f"time python -m cProfile -o /tmp/stat.prof -m bikeshed -f spec && gprof2dot -f pstats --skew=.0001 {root} {leaf} /tmp/stat.prof | xdot &", # noqa: S605 + os.system( # noqa s605 + f"time python -m cProfile -o /tmp/stat.prof -m bikeshed -f spec && gprof2dot -f pstats --skew=.0001 {root} {leaf} /tmp/stat.prof | xdot &", ) diff --git a/bikeshed/doctypes/manager.py b/bikeshed/doctypes/manager.py index 1c7d522362..74b1e416c5 100644 --- a/bikeshed/doctypes/manager.py +++ b/bikeshed/doctypes/manager.py @@ -166,7 +166,7 @@ def looselyMatch(self, rawStatus: str) -> bool: orgName, statusName = utils.splitOrg(rawStatus) if statusName and self.name.upper() != statusName.upper(): return False - if orgName and self.org.name != orgName.upper(): + if orgName and self.org.name != orgName.upper(): # noqa needless-bool return False return True diff --git a/bikeshed/h/dom.py b/bikeshed/h/dom.py index e177dc3e50..16015e6908 100644 --- a/bikeshed/h/dom.py +++ b/bikeshed/h/dom.py @@ -66,12 +66,7 @@ def escapeCSSIdent(val: str) -> str: ): ident += rf"\{code:x} " elif ( - code >= 0x80 - or code == 0x2D - or code == 0x5F - or 0x30 <= code <= 0x39 - or 0x41 <= code <= 0x5A - or 0x61 <= code <= 0x7A + code >= 0x80 or code in (0x2D, 0x5F) or 0x30 <= code <= 0x39 or 0x41 <= code <= 0x5A or 0x61 <= code <= 0x7A ): ident += chr(code) else: @@ -94,9 +89,8 @@ def validUrlUnit(char: str) -> bool: c = ord(char) if c < 0xA0: # ASCII range - if ( - c == 0x21 - or c == 0x24 + return ( + c in (0x21, 0x24) or 0x26 <= c <= 0x29 or 0x2A <= c <= 0x3B or c == 0x3D @@ -104,13 +98,11 @@ def validUrlUnit(char: str) -> bool: or c == 0x5F or 0x61 <= c <= 0x7A or c == 0x7E - ): - return True - return False + ) else: if 0xD800 <= c <= 0xDFFF or 0xFDD0 <= c <= 0xFDEF: return False - if (c % 0xFFFF) in [0xFFFE, 0xFFFF]: + if (c % 0xFFFF) in [0xFFFE, 0xFFFF]: # noqa needless-bool # Last two bytes are FFFE or FFFF return False return True @@ -745,7 +737,7 @@ def isOddNode(node: t.Any) -> bool: # Something other than an element node or string. if isinstance(node, str): return False - if isElement(node): + if isElement(node): # noqa needless-bool return False return True diff --git a/bikeshed/h/parser/preds.py b/bikeshed/h/parser/preds.py index 5e5f75d162..ad81c0015a 100644 --- a/bikeshed/h/parser/preds.py +++ b/bikeshed/h/parser/preds.py @@ -235,9 +235,7 @@ def isTagnameChar(ch: str) -> bool: if cp == 0xB7: return True if 0xC0 <= cp <= 0x1FFF: - if cp in (0xD7, 0xF7, 0x37E): - return False - return True + return cp not in (0xD7, 0xF7, 0x37E) if cp in (0x200C, 0x200D, 0x203F, 0x2040): return True if 0x2070 <= cp <= 0x218F: @@ -250,7 +248,7 @@ def isTagnameChar(ch: str) -> bool: return True if 0xFDF0 <= cp <= 0xFFFD: return True - if 0x10000 <= cp <= 0xEFFFF: + if 0x10000 <= cp <= 0xEFFFF: # noqa needless-bool return True return False @@ -258,7 +256,7 @@ def isTagnameChar(ch: str) -> bool: def isAttrNameChar(ch: str) -> bool: if len(ch) != 1: return False - if isWhitespace(ch) or ch in "/<>=\"'" or ord(ch) == 0: + if isWhitespace(ch) or ch in "/<>=\"'" or ord(ch) == 0: # noqa needless-bool return False return True diff --git a/bikeshed/h/serializer.py b/bikeshed/h/serializer.py index 3d41688e97..6626044563 100644 --- a/bikeshed/h/serializer.py +++ b/bikeshed/h/serializer.py @@ -187,7 +187,7 @@ def needsEndTag(self, el: t.ElementT, nextEl: Nodes | None = None) -> bool: if el.tag in ["dt", "dd"]: if nextEl is None: return False - if self.isElement(nextEl) and nextEl.tag in ["dt", "dd"]: + if self.isElement(nextEl) and nextEl.tag in ["dt", "dd"]: # noqa needless-bool return False return True return False diff --git a/bikeshed/markdown/markdown.py b/bikeshed/markdown/markdown.py index c8c129461d..48e4b86447 100644 --- a/bikeshed/markdown/markdown.py +++ b/bikeshed/markdown/markdown.py @@ -146,10 +146,9 @@ def inlineElementStart(line: str) -> bool: if tagname in inlineElements: return True assert blockElements is not None - if "-" in tagname and tagname not in blockElements: - # Assume custom elements are inline by default - return True - return False + + # Assume custom elements are inline by default + return "-" in tagname and tagname not in blockElements tokens: list[TokenT] = [] rawStack: list[RawTokenT] = [] diff --git a/bikeshed/messages.py b/bikeshed/messages.py index 92dbe75468..5f17837d25 100644 --- a/bikeshed/messages.py +++ b/bikeshed/messages.py @@ -43,7 +43,6 @@ class MessagesState: printOn: str = "everything" # Suppress *all* categories, *plus* the final success/fail message silent: bool = False - # printMode: str = "console" asciiOnly: bool = False fh: io.TextIOWrapper = t.cast("io.TextIOWrapper", sys.stdout) # noqa: RUF009 diff --git a/bikeshed/refs/source.py b/bikeshed/refs/source.py index 5adfe47b42..00ed687871 100644 --- a/bikeshed/refs/source.py +++ b/bikeshed/refs/source.py @@ -195,16 +195,16 @@ def allRefsIterator() -> t.Generator[t.RefWrapper, None, None]: def textRefsIterator(texts: list[str]) -> t.Generator[t.RefWrapper, None, None]: # Same as above, but only grabs those keyed to a given text - for text in texts: - yield from self.fetchRefs(text) + for x in texts: + yield from self.fetchRefs(x) def forRefsIterator(targetFors: str | list[str]) -> t.Generator[t.RefWrapper, None, None]: # Same as above, but only grabs those for certain values if isinstance(targetFors, str): targetFors = [targetFors] for for_ in targetFors: - for text in self.fors[for_]: - yield from self.fetchRefs(text) + for x in self.fors[for_]: + yield from self.fetchRefs(x) # Set up the initial list of refs to query if text: diff --git a/bikeshed/stylescript/manager.py b/bikeshed/stylescript/manager.py index 0450de7a89..dbd6381e6b 100644 --- a/bikeshed/stylescript/manager.py +++ b/bikeshed/stylescript/manager.py @@ -182,7 +182,7 @@ def insertable(self, allowList: t.BoolSet) -> bool: return False if self.data is None: return True - if self.data[1]: + if self.data[1]: # noqa needless-bool return True return False @@ -220,9 +220,7 @@ class Style(JCResource): script: Script | None = None def insertable(self, allowList: t.BoolSet) -> bool: - if f"style-{self.name}" not in allowList: - return False - return True + return f"style-{self.name}" in allowList def toElement(self, darkMode: bool = True) -> t.ElementT: with self.textPath.open("r", encoding="utf-8") as fh: