diff --git a/pyglossary/core.py b/pyglossary/core.py index 81af6795c..8261bd673 100644 --- a/pyglossary/core.py +++ b/pyglossary/core.py @@ -279,9 +279,7 @@ def checkCreateConfDir() -> None: def _in_virtualenv() -> bool: if hasattr(sys, "real_prefix"): return True - if hasattr(sys, "base_prefix") and sys.base_prefix != sys.prefix: - return True - return False + return hasattr(sys, "base_prefix") and sys.base_prefix != sys.prefix def getDataDir() -> str: diff --git a/pyglossary/glossary.py b/pyglossary/glossary.py index 4f9962bbd..1b683a2e4 100644 --- a/pyglossary/glossary.py +++ b/pyglossary/glossary.py @@ -82,16 +82,12 @@ def read( self._progressbar = progressbar - ok = self._read( + return self._read( filename=filename, format=format, direct=direct, **kwargs, ) - if not ok: - return False - - return True def addEntryObj(self, entry: "EntryType") -> None: self._data.append(entry) diff --git a/pyglossary/option.py b/pyglossary/option.py index c569ab2ef..be671cc95 100644 --- a/pyglossary/option.py +++ b/pyglossary/option.py @@ -127,9 +127,7 @@ def validateRaw(self, raw: str) -> bool: value, isValid = self.evaluate(raw) if not isValid: return False - if not self.validate(value): - return False - return True + return self.validate(value) def groupValues(self) -> "dict[str, Any] | None": # noqa: PLR6301 return None diff --git a/pyglossary/plugins/stardict.py b/pyglossary/plugins/stardict.py index 1ce711333..f88d89c86 100644 --- a/pyglossary/plugins/stardict.py +++ b/pyglossary/plugins/stardict.py @@ -157,9 +157,7 @@ def verifySameTypeSequence(s: str) -> bool: # maybe should just check it's in ("h", "m", "x") if not s.isalpha(): return False - if len(s) > 1: - return False - return True + return len(s) == 1 class XdxfTransformerType(Protocol): diff --git a/pyglossary/plugins/stardict_textual.py b/pyglossary/plugins/stardict_textual.py index 09a880675..042c0f63d 100644 --- a/pyglossary/plugins/stardict_textual.py +++ b/pyglossary/plugins/stardict_textual.py @@ -173,8 +173,7 @@ def renderDefiList( return defisWithFormat[0] defiFormatSet = set() - for _, _type in defisWithFormat: - defiFormatSet.add(_type) + defiFormatSet.update(_type for _, _type in defisWithFormat) if len(defiFormatSet) == 1: defis = [_defi for _defi, _ in defisWithFormat] diff --git a/pyglossary/ui/main.py b/pyglossary/ui/main.py index 62522482a..214e3af54 100644 --- a/pyglossary/ui/main.py +++ b/pyglossary/ui/main.py @@ -268,9 +268,7 @@ def shouldUseCMD(args: "argparse.Namespace") -> bool: return True if args.interactive: return True - if args.inputFilename and args.outputFilename: - return True - return False + return bool(args.inputFilename and args.outputFilename) def getRunner(args: "argparse.Namespace", ui_type: str) -> "Callable": diff --git a/pyglossary/xdxf/transform.py b/pyglossary/xdxf/transform.py index 1eb46d581..81c424805 100644 --- a/pyglossary/xdxf/transform.py +++ b/pyglossary/xdxf/transform.py @@ -91,7 +91,7 @@ def hasPrevText(prev: "None | str | Element") -> bool: "small", }: return True - if prev.text: + if prev.text: # noqa: SIM103 return True # print(prev) return False @@ -382,9 +382,7 @@ def shouldAddSep( # noqa: PLR6301 prev: "str | Element", ) -> bool: if isinstance(child, str): - if len(child) > 0 and child[0] in ".,;)": - return False - return True + return not (len(child) > 0 and child[0] in ".,;)") if child.tag in {"sub", "sup"}: return False diff --git a/scripts/plugin-doc.py b/scripts/plugin-doc.py index 3c110079f..8b653938c 100755 --- a/scripts/plugin-doc.py +++ b/scripts/plugin-doc.py @@ -177,9 +177,7 @@ def pluginIsActive(p): return False if not (p.canRead or p.canWrite): return False - if userPluginsDirPath in p.path.parents: - return False - return True + return userPluginsDirPath not in p.path.parents def getToolSourceLink(tool): diff --git a/scripts/wiki-formats.py b/scripts/wiki-formats.py index a5c777be3..5a26dd848 100755 --- a/scripts/wiki-formats.py +++ b/scripts/wiki-formats.py @@ -59,9 +59,7 @@ def pluginIsActive(p): return False if not (p.canRead or p.canWrite): return False - if userPluginsDirPath in p.path.parents: - return False - return True + return userPluginsDirPath not in p.path.parents def codeValue(x):