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 -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
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
""" # 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
+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
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
""" # noqa
from __future__ import annotations
import argparse
@@ -134,5 +134,3 @@ def appImage(args: argparse.Namespace) -> None:
toUpload(bldFile)
toUpload(updFile)
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
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
""" # 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
+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
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
""" # 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
+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
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
""" # 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
+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
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
""" # 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
+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
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
""" # 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
+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
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
""" # 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