From 100aad1256146083cee38f68551370f6edc72790 Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Sat, 4 Oct 2025 18:36:44 +0200 Subject: [PATCH] Update linting due to new Ruff rules --- novelWriter.py | 4 ++-- novelwriter/core/status.py | 2 +- novelwriter/core/tree.py | 2 +- novelwriter/error.py | 2 +- novelwriter/gui/doceditor.py | 8 ++++---- novelwriter/gui/docviewer.py | 2 +- novelwriter/gui/outline.py | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/novelWriter.py b/novelWriter.py index 797dfe23..78c8db27 100755 --- a/novelWriter.py +++ b/novelWriter.py @@ -7,8 +7,8 @@ import os import sys try: - import PyQt6.QtCore - import PyQt6.QtGui + import PyQt6.QtCore # noqa: F401 + import PyQt6.QtGui # noqa: F401 import PyQt6.QtWidgets # noqa: F401 except Exception: print("ERROR: Failed to load dependency PyQt6") diff --git a/novelwriter/core/status.py b/novelwriter/core/status.py index fc8bf85c..9a3d3194 100644 --- a/novelwriter/core/status.py +++ b/novelwriter/core/status.py @@ -183,7 +183,7 @@ class NWStatus: icon = NWStatus.createIcon(self._height, color, shape) return StatusEntry(simplified(data[2]), color, theme, shape, icon) except Exception: - logger.error("Could not parse entry %s", str(data)) + logger.error("Could not parse entry %s", data) return None def refreshIcons(self) -> None: diff --git a/novelwriter/core/tree.py b/novelwriter/core/tree.py index 4ee4b626..2f151cc4 100644 --- a/novelwriter/core/tree.py +++ b/novelwriter/core/tree.py @@ -89,7 +89,7 @@ class NWTree: """ if tHandle and tHandle in self._items: return self._items[tHandle] - logger.error("No tree item with handle '%s'", str(tHandle)) + logger.error("No tree item with handle '%s'", tHandle) return None def __contains__(self, tHandle: str) -> bool: diff --git a/novelwriter/error.py b/novelwriter/error.py index 59fafdff..0f1ff8fd 100644 --- a/novelwriter/error.py +++ b/novelwriter/error.py @@ -171,7 +171,7 @@ def exceptionHandler(exType: type, exValue: BaseException, exTrace: TracebackTyp from PyQt6.QtWidgets import QApplication - logger.critical("%s: %s", exType.__name__, str(exValue)) + logger.critical("%s: %s", exType.__name__, exValue) print_tb(exTrace) try: diff --git a/novelwriter/gui/doceditor.py b/novelwriter/gui/doceditor.py index c6773f24..339503d5 100644 --- a/novelwriter/gui/doceditor.py +++ b/novelwriter/gui/doceditor.py @@ -672,7 +672,7 @@ class GuiDocEditor(QPlainTextEdit): self.spellCheckStateChanged.emit(state) self.spellCheckDocument() - logger.debug("Spell check is set to '%s'", str(state)) + logger.debug("Spell check is set to '%s'", state) def spellCheckDocument(self) -> None: """Rerun the highlighter to update spell checking status of the @@ -785,7 +785,7 @@ class GuiDocEditor(QPlainTextEdit): elif action == nwDocAction.SC_SUB: self._wrapSelection(nwShortcode.SUB_O, nwShortcode.SUB_C) else: - logger.debug("Unknown or unsupported document action '%s'", str(action)) + logger.debug("Unknown or unsupported document action '%s'", action) self._allowAutoReplace(True) return False @@ -1750,7 +1750,7 @@ class GuiDocEditor(QPlainTextEdit): elif action == nwDocAction.BLOCK_TXT: text = temp else: - logger.error("Unknown or unsupported block format requested: '%s'", str(action)) + logger.error("Unknown or unsupported block format requested: '%s'", action) return nwDocAction.NO_ACTION, "", 0 return action, text, offset @@ -1760,7 +1760,7 @@ class GuiDocEditor(QPlainTextEdit): cursor = self.textCursor() block = cursor.block() if not block.isValid(): - logger.debug("Invalid block selected for action '%s'", str(action)) + logger.debug("Invalid block selected for action '%s'", action) return False action, text, offset = self._processBlockFormat(action, block.text()) diff --git a/novelwriter/gui/docviewer.py b/novelwriter/gui/docviewer.py index 10ef9c46..a043e947 100644 --- a/novelwriter/gui/docviewer.py +++ b/novelwriter/gui/docviewer.py @@ -291,7 +291,7 @@ class GuiDocViewer(QTextBrowser): elif action == nwDocAction.SEL_PARA: self._makeSelection(QTextCursor.SelectionType.BlockUnderCursor) else: - logger.debug("Unknown or unsupported document action '%s'", str(action)) + logger.debug("Unknown or unsupported document action '%s'", action) return False return True diff --git a/novelwriter/gui/outline.py b/novelwriter/gui/outline.py index 3df01d3f..4a76712f 100644 --- a/novelwriter/gui/outline.py +++ b/novelwriter/gui/outline.py @@ -586,7 +586,7 @@ class GuiOutlineTree(QTreeWidget): try: for name, (hidden, width) in colState.items(): if name not in nwOutline.__members__: - logger.warning("Ignored unknown outline column '%s'", str(name)) + logger.warning("Ignored unknown outline column '%s'", name) continue tmpOrder.append(nwOutline[name]) tmpHidden[nwOutline[name]] = hidden