Fix linting errors in the main code

This commit is contained in:
Veronica Berglyd Olsen
2025-04-07 17:18:43 +02:00
parent dab48d43a5
commit 8ed3bd889d
66 changed files with 434 additions and 344 deletions
+5 -1
View File
@@ -25,7 +25,8 @@ from __future__ import annotations
import logging
from PyQt6.QtGui import QCloseEvent
from typing import TYPE_CHECKING
from PyQt6.QtWidgets import (
QDialogButtonBox, QHBoxLayout, QLabel, QTextBrowser, QVBoxLayout, QWidget
)
@@ -37,6 +38,9 @@ from novelwriter.extensions.modified import NDialog
from novelwriter.extensions.versioninfo import VersionInfoWidget
from novelwriter.types import QtAlignRightTop, QtDialogClose, QtHexArgb
if TYPE_CHECKING:
from PyQt6.QtGui import QCloseEvent
logger = logging.getLogger(__name__)
+5 -5
View File
@@ -131,11 +131,11 @@ class GuiDocMerge(NDialog):
@classmethod
def getData(cls, parent: QWidget, handle: str, items: list[str]) -> tuple[dict, bool]:
"""Pop the dialog and return the result."""
cls = GuiDocMerge(parent, handle, items)
cls.exec()
data = cls.data()
accepted = cls.result() == QtAccepted
cls.softDelete()
dialog = cls(parent, handle, items)
dialog.exec()
data = dialog.data()
accepted = dialog.result() == QtAccepted
dialog.softDelete()
return data, accepted
##
+5 -5
View File
@@ -178,11 +178,11 @@ class GuiDocSplit(NDialog):
@classmethod
def getData(cls, parent: QWidget, handle: str) -> tuple[dict, list[str], bool]:
"""Pop the dialog and return the result."""
cls = GuiDocSplit(parent, handle)
cls.exec()
data, text = cls.data()
accepted = cls.result() == QtAccepted
cls.softDelete()
dialog = cls(parent, handle)
dialog.exec()
data, text = dialog.data()
accepted = dialog.result() == QtAccepted
dialog.softDelete()
return data, text, accepted
##
+5 -5
View File
@@ -82,9 +82,9 @@ class GuiEditLabel(NDialog):
@classmethod
def getLabel(cls, parent: QWidget, text: str) -> tuple[str, bool]:
"""Pop the dialog and return the result."""
cls = GuiEditLabel(parent, text=text)
cls.exec()
label = cls.itemLabel
accepted = cls.result() == QtAccepted
cls.softDelete()
dialog = cls(parent, text=text)
dialog.exec()
label = dialog.itemLabel
accepted = dialog.result() == QtAccepted
dialog.softDelete()
return label, accepted
+3 -3
View File
@@ -432,7 +432,7 @@ class GuiPreferences(NDialog):
self.textWidth.setSingleStep(10)
self.textWidth.setValue(CONFIG.textWidth)
self.mainForm.addRow(
self.tr("Maximum text width in \"Normal Mode\""), self.textWidth,
self.tr('Maximum text width in "Normal Mode"'), self.textWidth,
self.tr("Set to 0 to disable this feature."), unit=self.tr("px")
)
@@ -443,7 +443,7 @@ class GuiPreferences(NDialog):
self.focusWidth.setSingleStep(10)
self.focusWidth.setValue(CONFIG.focusWidth)
self.mainForm.addRow(
self.tr("Maximum text width in \"Focus Mode\""), self.focusWidth,
self.tr('Maximum text width in "Focus Mode"'), self.focusWidth,
self.tr("The maximum width cannot be disabled."), unit=self.tr("px")
)
@@ -451,7 +451,7 @@ class GuiPreferences(NDialog):
self.hideFocusFooter = NSwitch(self)
self.hideFocusFooter.setChecked(CONFIG.hideFocusFooter)
self.mainForm.addRow(
self.tr("Hide document footer in \"Focus Mode\""), self.hideFocusFooter,
self.tr('Hide document footer in "Focus Mode"'), self.hideFocusFooter,
self.tr("Hide the information bar in the document editor.")
)
+5 -5
View File
@@ -122,11 +122,11 @@ class GuiQuoteSelect(NDialog):
@classmethod
def getQuote(cls, parent: QWidget, current: str = "") -> tuple[str, bool]:
"""Pop the dialog and return the result."""
cls = GuiQuoteSelect(parent, current=current)
cls.exec()
quote = cls._selected
accepted = cls.result() == QtAccepted
cls.softDelete()
dialog = cls(parent, current=current)
dialog.exec()
quote = dialog._selected
accepted = dialog.result() == QtAccepted
dialog.softDelete()
return quote, accepted
##
+8 -6
View File
@@ -26,9 +26,9 @@ from __future__ import annotations
import logging
from pathlib import Path
from typing import TYPE_CHECKING
from PyQt6.QtCore import Qt, pyqtSignal, pyqtSlot
from PyQt6.QtGui import QCloseEvent
from PyQt6.QtWidgets import (
QAbstractItemView, QApplication, QDialogButtonBox, QFileDialog,
QHBoxLayout, QLineEdit, QListWidget, QVBoxLayout, QWidget
@@ -41,6 +41,9 @@ from novelwriter.extensions.configlayout import NColorLabel
from novelwriter.extensions.modified import NDialog, NIconToolButton
from novelwriter.types import QtDialogClose, QtDialogSave
if TYPE_CHECKING:
from PyQt6.QtGui import QCloseEvent
logger = logging.getLogger(__name__)
@@ -242,8 +245,7 @@ class GuiWordList(NDialog):
def _listWords(self) -> list[str]:
"""List all words in the list box."""
result = []
for i in range(self.listBox.count()):
if (item := self.listBox.item(i)) and (word := item.text().strip()):
result.append(word)
return result
return [
word for i in range(self.listBox.count())
if (item := self.listBox.item(i)) and (word := item.text().strip())
]