From 44d117c91d373aec872afbc32eabfb9dc82a6841 Mon Sep 17 00:00:00 2001
From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com>
Date: Wed, 27 Aug 2025 21:01:11 +0200
Subject: [PATCH] Update linting for utils
---
docs/source/conf.py | 2 +-
i18n/qtbase.py | 2 +-
novelWriter.py | 2 +-
pkgutils.py | 9 +--------
utils/assets.py | 13 +------------
utils/build_appimage.py | 4 +---
utils/build_binary.py | 7 ++-----
utils/build_debian.py | 9 +++------
utils/build_windows.py | 9 +--------
utils/common.py | 15 +++------------
utils/docs.py | 10 +---------
utils/icon_themes.py | 13 +------------
12 files changed, 17 insertions(+), 78 deletions(-)
diff --git a/docs/source/conf.py b/docs/source/conf.py
index b3d3d41f..bfedb52a 100644
--- a/docs/source/conf.py
+++ b/docs/source/conf.py
@@ -1,7 +1,7 @@
"""
Configuration file for the Sphinx documentation builder.
Documentation: http://www.sphinx-doc.org/en/master/config
-"""
+""" # noqa
# -- Imports -----------------------------------------------------------------
diff --git a/i18n/qtbase.py b/i18n/qtbase.py
index 3126bea3..e40279cd 100644
--- a/i18n/qtbase.py
+++ b/i18n/qtbase.py
@@ -8,7 +8,7 @@ not yet have a qtbase_xx.qm file shipped with Qt.
If a qtbase_xx.qm file already exists, do not add a translation for the
entries generated from this file.
-"""
+""" # noqa
from PyQt6.QtCore import QT_TRANSLATE_NOOP
diff --git a/novelWriter.py b/novelWriter.py
index 63d437e1..797dfe23 100755
--- a/novelWriter.py
+++ b/novelWriter.py
@@ -2,7 +2,7 @@
"""
novelWriter – Start Script
==========================
-"""
+""" # noqa
import os
import sys
diff --git a/pkgutils.py b/pkgutils.py
index fd9ecf67..4ef16fd5 100755
--- a/pkgutils.py
+++ b/pkgutils.py
@@ -23,7 +23,7 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
-"""
+""" # noqa
from __future__ import annotations
import argparse
@@ -50,7 +50,6 @@ OS_WIN = sys.platform.startswith("win32")
def printVersion(args: argparse.Namespace) -> None:
"""Print the novelWriter version and exit."""
print(extractVersion(beQuiet=True)[0], end=None)
- return
def installPackages(args: argparse.Namespace) -> None:
@@ -79,8 +78,6 @@ def installPackages(args: argparse.Namespace) -> None:
print(str(exc))
sys.exit(1)
- return
-
def cleanBuildDirs(args: argparse.Namespace) -> None:
"""Recursively delete the 'build' and 'dist' folders."""
@@ -111,8 +108,6 @@ def cleanBuildDirs(args: argparse.Namespace) -> None:
print("")
- return
-
def genMacOSPlist(args: argparse.Namespace) -> None:
"""Set necessary values for .plist file for MacOS build."""
@@ -134,8 +129,6 @@ def genMacOSPlist(args: argparse.Namespace) -> None:
print(f"Writing Info.plist to {outDir}/Info.plist")
writeFile(outDir / "Info.plist", plistXML)
- return
-
if __name__ == "__main__":
"""Parse command line options and run the commands."""
diff --git a/utils/assets.py b/utils/assets.py
index 1849c696..7f0222cd 100644
--- a/utils/assets.py
+++ b/utils/assets.py
@@ -17,7 +17,7 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
-"""
+""" # noqa
from __future__ import annotations
import argparse
@@ -62,8 +62,6 @@ def buildSampleZip(args: argparse.Namespace | None = None) -> None:
print(f"Built file: {dstSample}")
print("")
- return
-
def importI18nUpdates(args: argparse.Namespace) -> None:
"""Import new translation files from a zip file."""
@@ -94,8 +92,6 @@ def importI18nUpdates(args: argparse.Namespace) -> None:
print("")
- return
-
def updateTranslationSources(args: argparse.Namespace) -> None:
"""Build the lang.ts files for Qt Linguist."""
@@ -157,8 +153,6 @@ def updateTranslationSources(args: argparse.Namespace) -> None:
print("")
- return
-
def buildTranslationAssets(args: argparse.Namespace | None = None) -> None:
"""Build the lang.qm files for Qt Linguist."""
@@ -203,8 +197,6 @@ def buildTranslationAssets(args: argparse.Namespace | None = None) -> None:
print("")
- return
-
def cleanBuiltAssets(args: argparse.Namespace | None = None) -> None:
"""Remove assets built by this script."""
@@ -223,8 +215,6 @@ def cleanBuiltAssets(args: argparse.Namespace | None = None) -> None:
print("")
- return
-
def buildAllAssets(args: argparse.Namespace) -> None:
"""Build all assets."""
@@ -232,4 +222,3 @@ def buildAllAssets(args: argparse.Namespace) -> None:
buildSampleZip()
buildTranslationAssets()
buildPdfDocAssets()
- return
diff --git a/utils/build_appimage.py b/utils/build_appimage.py
index d32a377e..ff52cd3f 100644
--- a/utils/build_appimage.py
+++ b/utils/build_appimage.py
@@ -17,7 +17,7 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
-"""
+""" # noqa
from __future__ import annotations
import argparse
@@ -134,5 +134,3 @@ def appImage(args: argparse.Namespace) -> None:
toUpload(bldFile)
toUpload(updFile)
toUpload(shaFile)
-
- return
diff --git a/utils/build_binary.py b/utils/build_binary.py
index 1ffa4797..e58321e5 100644
--- a/utils/build_binary.py
+++ b/utils/build_binary.py
@@ -17,7 +17,7 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
-"""
+""" # noqa
from __future__ import annotations
import argparse
@@ -25,7 +25,7 @@ import argparse
def runPyinstaller() -> None:
"""Run the pyinstaller."""
- import PyInstaller.__main__
+ import PyInstaller.__main__ # type: ignore
build = ["novelWriter.py", "--clean", "--windowed", "--onedir", "--noconfirm"]
build += ["--name", "novelwriter"]
@@ -35,10 +35,7 @@ def runPyinstaller() -> None:
build += ["--add-data", "novelwriter/assets:assets"]
PyInstaller.__main__.run(build)
- return
-
def main(args: argparse.Namespace) -> None:
"""Entry point function."""
runPyinstaller()
- return
diff --git a/utils/build_debian.py b/utils/build_debian.py
index e555ff95..6feac9de 100644
--- a/utils/build_debian.py
+++ b/utils/build_debian.py
@@ -17,7 +17,7 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
-"""
+""" # noqa
from __future__ import annotations
import argparse
@@ -155,17 +155,16 @@ def makeDebianPackage(
def debian(args: argparse.Namespace) -> None:
- """Build a .deb package"""
+ """Build a .deb package."""
if sys.platform != "linux":
print("ERROR: Command 'build-deb' can only be used on Linux")
sys.exit(1)
signKey = SIGN_KEY if args.sign else None
makeDebianPackage(signKey)
- return
def launchpad(args: argparse.Namespace) -> None:
- """Wrapper for building Debian packages for Launchpad."""
+ """Build Debian packages for Launchpad."""
if sys.platform != "linux":
print("ERROR: Command 'build-ubuntu' can only be used on Linux")
sys.exit(1)
@@ -215,5 +214,3 @@ def launchpad(args: argparse.Namespace) -> None:
for dCmd in dputCmd:
print(f" > {dCmd}")
print("")
-
- return
diff --git a/utils/build_windows.py b/utils/build_windows.py
index 76fdc281..523797da 100644
--- a/utils/build_windows.py
+++ b/utils/build_windows.py
@@ -17,7 +17,7 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
-"""
+""" # noqa
from __future__ import annotations
import argparse
@@ -60,8 +60,6 @@ def prepareCode(outDir: Path) -> None:
print("Done")
print("")
- return
-
def embedPython(bldDir: Path, outDir: Path) -> None:
"""Embed Python library."""
@@ -82,8 +80,6 @@ def embedPython(bldDir: Path, outDir: Path) -> None:
print("Done")
print("")
- return
-
def installRequirements(libDir: Path) -> None:
"""Install dependencies."""
@@ -93,7 +89,6 @@ def installRequirements(libDir: Path) -> None:
])
print("Done")
print("")
- return
def main(args: argparse.Namespace) -> None:
@@ -157,5 +152,3 @@ def main(args: argparse.Namespace) -> None:
print("")
print("Done")
print("")
-
- return
diff --git a/utils/common.py b/utils/common.py
index 1784ed01..d8590225 100644
--- a/utils/common.py
+++ b/utils/common.py
@@ -17,7 +17,7 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
-"""
+""" # noqa
from __future__ import annotations
import shutil
@@ -88,7 +88,6 @@ def copySourceCode(dst: Path) -> None:
if item.is_file():
shutil.copyfile(item, dst / relSrc)
print("Copied:", relSrc, flush=True)
- return
def copyPackageFiles(dst: Path, setupPy: bool = False) -> None:
@@ -114,8 +113,6 @@ def copyPackageFiles(dst: Path, setupPy: bool = False) -> None:
text = text.replace("setup/description_pypi.md", "data/description_short.txt")
writeFile(dst / "pyproject.toml", text)
- return
-
def toUpload(srcPath: str | Path, dstName: str | None = None) -> None:
"""Copy a file produced by one of the build functions to the upload
@@ -125,7 +122,6 @@ def toUpload(srcPath: str | Path, dstName: str | None = None) -> None:
uplDir.mkdir(exist_ok=True)
srcPath = Path(srcPath)
shutil.copyfile(srcPath, uplDir / (dstName or srcPath.name))
- return
def makeCheckSum(sumFile: str, cwd: Path | None = None) -> str:
@@ -174,9 +170,7 @@ def appdataXml() -> str:
"""Generate the appdata XML content."""
raw = readFile(SETUP_DIR / "description_short.txt")
desc = " ".join(raw.strip().splitlines()).strip()
- xml = readFile(SETUP_DIR / "novelwriter.appdata.xml")
- xml = xml.format(description=desc)
- return xml
+ return readFile(SETUP_DIR / "novelwriter.appdata.xml").format(description=desc)
def readFile(file: Path) -> str:
@@ -197,7 +191,6 @@ def freshFolder(path: Path) -> None:
print("Removing:", str(path), flush=True)
shutil.rmtree(path)
path.mkdir()
- return
def systemCall(cmd: list, cwd: Path | str | None = None, env: dict | None = None) -> int:
@@ -213,7 +206,7 @@ def systemCall(cmd: list, cwd: Path | str | None = None, env: dict | None = None
def removeRedundantQt(qtBase: Path) -> None:
- """Delete Qt files that are not needed"""
+ """Delete Qt files that are not needed."""
def unlinkIfFound(file: Path) -> None:
if file.is_file():
@@ -274,5 +267,3 @@ def removeRedundantQt(qtBase: Path) -> None:
deleteFolder(qt6Dir / "qml")
deleteFolder(plugDir / "qmlls")
deleteFolder(plugDir / "qmllint")
-
- return
diff --git a/utils/docs.py b/utils/docs.py
index 7a4de94b..856abcfb 100644
--- a/utils/docs.py
+++ b/utils/docs.py
@@ -17,7 +17,7 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
-"""
+""" # noqa
from __future__ import annotations
import argparse
@@ -61,12 +61,9 @@ def updateDocsTranslationSources(args: argparse.Namespace) -> None:
print("Done")
print("")
- return
-
def buildHtmlDocs(args: argparse.Namespace | None = None) -> None:
"""Build the documentation files."""
-
print("")
print("Building HTML Docs")
print("==================")
@@ -105,12 +102,9 @@ def buildHtmlDocs(args: argparse.Namespace | None = None) -> None:
print("")
- return
-
def buildPdfDocAssets(args: argparse.Namespace | None = None) -> None:
"""Build the documentation PDF files."""
-
print("")
print("Building Docs Manuals")
print("=====================")
@@ -146,5 +140,3 @@ def buildPdfDocAssets(args: argparse.Namespace | None = None) -> None:
raise Exception(f"Build returned error code {ex}")
print("")
-
- return
diff --git a/utils/icon_themes.py b/utils/icon_themes.py
index daa6f83f..cb906b01 100644
--- a/utils/icon_themes.py
+++ b/utils/icon_themes.py
@@ -17,7 +17,7 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
-"""
+""" # noqa
from __future__ import annotations
import argparse
@@ -197,7 +197,6 @@ def _writeThemeFile(
out.write(f"icon:{key:<15s} = {_fixXml(svg)}\n")
print(f"- Wrote: {len(icons)} icons")
print(f"- Target: {path.relative_to(UTILS.parent)}")
- return
def _updateRepo(path: Path, name: str) -> None:
@@ -208,7 +207,6 @@ def _updateRepo(path: Path, name: str) -> None:
else:
subprocess.call(["git", "pull"], cwd=path)
print("")
- return
def _downloadIconPack(path: Path, name: str) -> None:
@@ -220,7 +218,6 @@ def _downloadIconPack(path: Path, name: str) -> None:
with zipfile.ZipFile(zipFile, "r") as inFile:
inFile.extractall(path)
print("")
- return
def processMaterialIcons(workDir: Path, iconsDir: Path, jobs: dict) -> None:
@@ -257,8 +254,6 @@ def processMaterialIcons(workDir: Path, iconsDir: Path, jobs: dict) -> None:
print("")
- return
-
def processFontAwesome(workDir: Path, iconsDir: Path, jobs: dict) -> None:
"""Process Font Awesome icons of a given spec and write output file."""
@@ -303,8 +298,6 @@ def processFontAwesome(workDir: Path, iconsDir: Path, jobs: dict) -> None:
print("")
- return
-
def processRemix(workDir: Path, iconsDir: Path, jobs: dict) -> None:
"""Process Remix icons of a given spec and write output file."""
@@ -347,8 +340,6 @@ def processRemix(workDir: Path, iconsDir: Path, jobs: dict) -> None:
print("")
- return
-
def main(args: argparse.Namespace) -> None:
"""Build icon themes entry point."""
@@ -423,5 +414,3 @@ def main(args: argparse.Namespace) -> None:
print("Done")
print("")
-
- return