Skip to content

Commit

Permalink
fix ruff 0.3.5 errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ilius committed Apr 11, 2024
1 parent f8e5bd6 commit aaf7e15
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 29 deletions.
4 changes: 1 addition & 3 deletions pyglossary/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 1 addition & 5 deletions pyglossary/glossary.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 1 addition & 3 deletions pyglossary/option.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions pyglossary/plugins/stardict.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
3 changes: 1 addition & 2 deletions pyglossary/plugins/stardict_textual.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
4 changes: 1 addition & 3 deletions pyglossary/ui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down
6 changes: 2 additions & 4 deletions pyglossary/xdxf/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions scripts/plugin-doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 1 addition & 3 deletions scripts/wiki-formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit aaf7e15

Please sign in to comment.