Update linting for utils

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