Skip to content

Commit 2fec3e1

Browse files
committed
Initial mypy fixes
1 parent 56721af commit 2fec3e1

4 files changed

Lines changed: 17 additions & 6 deletions

File tree

nton/gui/widgets.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
from PySide6.QtCore import Signal
2-
from PySide6.QtGui import QDragEnterEvent, QDragLeaveEvent
2+
from PySide6.QtGui import QDragEnterEvent, QDragLeaveEvent, QMouseEvent
33
from PySide6.QtWidgets import QLabel, QStackedWidget
44

55

66
class FileDropWidget(QStackedWidget):
7-
def __init__(self, *args, **kwargs):
7+
def __init__(self, *args, **kwargs) -> None:
88
super().__init__(*args, **kwargs)
99
self.setAcceptDrops(True)
1010

11-
def dragEnterEvent(self, event: QDragEnterEvent):
11+
def dragEnterEvent(self, event: QDragEnterEvent) -> None:
1212
if event.mimeData().hasUrls():
1313
event.accept()
1414
self.window().openLabel.setStyleSheet(
@@ -31,5 +31,5 @@ def dragLeaveEvent(self, event: QDragLeaveEvent) -> None:
3131
class ClickableLabel(QLabel):
3232
clicked = Signal() # This signal will be emitted when the label is clicked
3333

34-
def mousePressEvent(self, event):
34+
def mousePressEvent(self, event: QMouseEvent) -> None:
3535
self.clicked.emit() # Emit the signal when the label is clicked

nton/nstool.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ def verify(path: Path, type_: str) -> str | int | None:
1616
Verify if the Nintendo Switch file is valid.
1717
Returns an empty string if valid, an error str or return code otherwise.
1818
"""
19+
if not BIN or not Path(BIN).is_file():
20+
raise EnvironmentError("nstool binary was not found. Please ensure nstool is installed and in your PATH.")
21+
1922
if not path:
2023
raise ValueError("The path must not be empty.")
2124
if not isinstance(path, Path):
@@ -57,6 +60,9 @@ def get_nacp(asset_path: Path, output_path: Path) -> str | int | None:
5760
5861
Returns an empty string if valid, an error str or return code otherwise.
5962
"""
63+
if not BIN or not Path(BIN).is_file():
64+
raise EnvironmentError("nstool binary was not found. Please ensure nstool is installed and in your PATH.")
65+
6066
try:
6167
subprocess.check_output(
6268
[
@@ -86,6 +92,9 @@ def get_icon(asset_path: Path, output_path: Path) -> str | int | None:
8692
8793
Returns an empty string if valid, an error str or return code otherwise.
8894
"""
95+
if not BIN or not Path(BIN).is_file():
96+
raise EnvironmentError("nstool binary was not found. Please ensure nstool is installed and in your PATH.")
97+
8998
try:
9099
subprocess.check_output(
91100
[

pyinstaller.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
["nton/bin", "nton/bin"],
2929
["nton/gui/main.ui", "nton/gui"]
3030
]
31-
HIDDEN_IMPORTS = []
3231
EXTRA_ARGS = [
3332
"-y"
3433
]
@@ -83,7 +82,6 @@
8382
["-D", "-F"][args.one_file],
8483
["-w", "-c"][args.console],
8584
*itertools.chain(*[["--add-data", ":".join(x)] for x in ADDITIONAL_DATA]),
86-
*itertools.chain(*[["--hidden-import", x] for x in HIDDEN_IMPORTS]),
8785
"--version-file", str(version_file),
8886
*EXTRA_ARGS
8987
])

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,7 @@ disallow_untyped_defs = true
8181
follow_imports = "silent"
8282
ignore_missing_imports = true
8383
no_implicit_optional = true
84+
85+
[[tool.mypy.overrides]]
86+
module = "nton.gui.resources"
87+
ignore_errors = true

0 commit comments

Comments
 (0)