Skip to content

Commit a139d29

Browse files
authored
Fix #47, updated some configs and types from typeshed (#173)
* Updated configs * Updated typings * Updated some code * Fix #47 * Revert mypy stuff
1 parent 9553271 commit a139d29

38 files changed

+378
-1424
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ reportMissingSuperCall="none" # False positives on base classes
2121
reportPropertyTypeMismatch="error"
2222
reportUninitializedInstanceVariable="error"
2323
reportUnnecessaryTypeIgnoreComment="error"
24-
reportUnusedCallResult="none"
2524
# Exclude from scanning when running pyright
2625
exclude = [
2726
# Auto generated, produces unecessary `# type: ignore`
@@ -32,6 +31,7 @@ ignore = [
3231
# We expect stub files to be incomplete or contain useless statements
3332
"**/*.pyi",
3433
]
34+
reportUnusedCallResult="none"
3535
# Type stubs may not be completable
3636
reportMissingTypeStubs = "warning"
3737
# False positives with TYPE_CHECKING

scripts/build.ps1

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
& "$PSScriptRoot/compile_resources.ps1"
22
pyinstaller `
33
--onefile `
4-
--windowed `
54
--additional-hooks-dir=Pyinstaller/hooks `
65
--icon=res/icon.ico `
76
--splash=res/splash.png `

scripts/lint.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ $exitCodes = 0
44

55
Write-Host "`nRunning autofixes..."
66
isort src/ typings/
7-
autopep8 src/ typings/ --in-place
7+
autopep8 $(git ls-files '**.py*') --in-place
88

99
Write-Host "`nRunning Pyright..."
1010
$Env:PYRIGHT_PYTHON_FORCE_VERSION = 'latest'

scripts/requirements-dev.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,6 @@ pyright
2727
qt6-applications
2828
# Types
2929
pywin32-stubs>=1.0.7 # Added error types
30+
types-keyboard
31+
types-pyautogui
3032
typing-extensions

src/AutoSplit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ def __init__(self, parent: QWidget | None = None): # pylint: disable=too-many-s
206206
self.show()
207207

208208
try:
209-
import pyi_splash # type: ignore # pylint: disable=import-outside-toplevel
209+
import pyi_splash # pyright: ignore[reportMissingModuleSource] # pylint: disable=import-outside-toplevel
210210
pyi_splash.close()
211211
except ModuleNotFoundError:
212212
pass

src/region_selection.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ def __get_window_from_point(x: int, y: int):
149149
# Want to pull the parent window from the window handle
150150
# By using GetAncestor we are able to get the parent window instead
151151
# of the owner window.
152+
# TODO: Fix stubs, IsChild should return a boolean
152153
while win32gui.IsChild(win32gui.GetParent(hwnd), hwnd):
153154
hwnd = cast(int, user32.GetAncestor(hwnd, GA_ROOT))
154155

src/user_profile.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ def __load_settings_from_file(autosplit: AutoSplit, load_settings_file_path: str
137137
set_hotkey(autosplit, hotkey, cast(str, autosplit.settings_dict[hotkey_name]))
138138

139139
change_capture_method(cast(CaptureMethodEnum, autosplit.settings_dict["capture_method"]), autosplit)
140-
autosplit.capture_method.recover_window(autosplit.settings_dict["captured_window_title"], autosplit)
140+
if autosplit.settings_dict["capture_method"] != CaptureMethodEnum.VIDEO_CAPTURE_DEVICE:
141+
autosplit.capture_method.recover_window(autosplit.settings_dict["captured_window_title"], autosplit)
141142
if not autosplit.capture_method.check_selected_region_exists(autosplit):
142143
autosplit.live_image.setText("Reload settings after opening"
143144
+ f'\n"{autosplit.settings_dict["captured_window_title"]}"'

src/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ def is_valid_hwnd(hwnd: int):
4646
if not hwnd:
4747
return False
4848
if sys.platform == "win32":
49+
# TODO: Fix stubs, IsWindow should return a boolean
4950
return bool(win32gui.IsWindow(hwnd) and win32gui.GetWindowText(hwnd))
5051
return True
5152

@@ -104,6 +105,6 @@ def wrapped(*args: Any, **kwargs: Any):
104105
# Shared strings
105106
# Set AUTOSPLIT_BUILD_NUMBER to an empty string to generate a clean version number
106107
# AUTOSPLIT_BUILD_NUMBER = "" # pyright: ignore[reportConstantRedefinition] # noqa: F811
107-
AUTOSPLIT_VERSION = "2.0.0-alpha.5" + (f"-{AUTOSPLIT_BUILD_NUMBER}" if AUTOSPLIT_BUILD_NUMBER else "")
108+
AUTOSPLIT_VERSION = "2.0.0-alpha.6" + (f"-{AUTOSPLIT_BUILD_NUMBER}" if AUTOSPLIT_BUILD_NUMBER else "")
108109
START_AUTO_SPLITTER_TEXT = "Start Auto Splitter"
109110
GITHUB_REPOSITORY = AUTOSPLIT_GITHUB_REPOSITORY

typings/PyInstaller/__init__.pyi

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from typing_extensions import LiteralString
2+
3+
from PyInstaller import compat as compat
4+
5+
__all__ = ("HOMEPATH", "PLATFORM", "__version__", "DEFAULT_DISTPATH", "DEFAULT_SPECPATH", "DEFAULT_WORKPATH")
6+
__version__: str = ...
7+
HOMEPATH: str = ...
8+
DEFAULT_SPECPATH: str = ...
9+
DEFAULT_DISTPATH: str = ...
10+
DEFAULT_WORKPATH: str = ...
11+
PLATFORM: LiteralString = ...

typings/PyInstaller/__main__.pyi

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# https://pyinstaller.org/en/stable/usage.html#running-pyinstaller-from-python-code
2+
from collections.abc import Iterable
3+
4+
from _typeshed import SupportsKeysAndGetItem
5+
from typing_extensions import TypeAlias
6+
7+
# Used to update PyInstaller.config.CONF
8+
_PyIConfig: TypeAlias = (
9+
SupportsKeysAndGetItem[str, bool | str | list[str] | None] | Iterable[tuple[str, bool | str | list[str] | None]]
10+
)
11+
12+
13+
def run(pyi_args: Iterable[str] | None = ..., pyi_config: _PyIConfig | None = ...) -> None: ...

0 commit comments

Comments
 (0)