Skip to content

Commit 9f6cf53

Browse files
committed
Update Ruff to 0.13.0
1 parent 14e93e7 commit 9f6cf53

18 files changed

+107
-76
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ dev = [
5454
"dprint-py>=0.50.0.0",
5555
"mypy[faster-cache] >=1.16",
5656
"pyright[nodejs] >=1.1.400", # reportPrivateImportUsage behaviour change
57-
"ruff >=0.12.0",
57+
"ruff >=0.13.0",
5858
#
5959
# Types
6060
"types-PyAutoGUI",

ruff.toml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@
88
# https://docs.astral.sh/ruff/configuration/
99
line-length = 100
1010
preview = true
11-
required-version = ">=0.11.0" # tool.ruff.target-version is inferred from project.requires-python
11+
required-version = ">=0.13.0" # tool.ruff.target-version is inferred from project.requires-python
1212

1313
[format]
1414
docstring-code-format = true
1515

1616
[lint]
17+
future-annotations = true
1718
select = ["ALL"]
1819
# https://docs.astral.sh/ruff/rules/
1920
ignore = [
@@ -34,8 +35,6 @@ ignore = [
3435
"ERA001", # eradicate: commented-out-code
3536
# contextlib.suppress is roughly 3x slower than try/except
3637
"SIM105", # flake8-simplify: use-contextlib-suppress
37-
# Negative performance impact and more verbose https://github.com/astral-sh/ruff/issues/7871
38-
"UP038", # non-pep604-isinstance
3938
# Not colored correctly in Pylance https://github.com/microsoft/pylance-release/issues/6942
4039
"UP047", # non-pep695-generic-function
4140
# Checked by type-checker (pyright/mypy)
@@ -103,8 +102,6 @@ ignore = [
103102
###
104103
"CPY001", # flake8-copyright
105104
"PTH", # flake8-use-pathlib
106-
# Ignore until linux support
107-
"EXE", # flake8-executable
108105
]
109106

110107
# https://docs.astral.sh/ruff/settings/#flake8-implicit-str-concat

src/AutoControlledThread.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
from typing import TYPE_CHECKING
24

35
from PySide6 import QtCore
@@ -10,7 +12,7 @@
1012

1113

1214
class AutoControlledThread(QtCore.QThread):
13-
def __init__(self, autosplit: "AutoSplit"):
15+
def __init__(self, autosplit: AutoSplit):
1416
self._autosplit_ref = autosplit
1517
super().__init__()
1618

src/AutoSplitImage.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
import os
24
import tomllib
35
from enum import IntEnum, auto
@@ -67,39 +69,39 @@ def is_ocr(self):
6769
"""
6870
return bool(self.texts)
6971

70-
def get_delay_time(self, default: "AutoSplit | int"):
72+
def get_delay_time(self, default: AutoSplit | int):
7173
"""Get image's delay time or fallback to the default value from spinbox."""
7274
if self.__delay_time is not None:
7375
return self.__delay_time
7476
if isinstance(default, int):
7577
return default
7678
return default.settings_dict["default_delay_time"]
7779

78-
def __get_comparison_method_index(self, default: "AutoSplit | int"):
80+
def __get_comparison_method_index(self, default: AutoSplit | int):
7981
"""Get image's comparison or fallback to the default value from combobox."""
8082
if self.__comparison_method is not None:
8183
return self.__comparison_method
8284
if isinstance(default, int):
8385
return default
8486
return default.settings_dict["default_comparison_method"]
8587

86-
def get_pause_time(self, default: "AutoSplit | float"):
88+
def get_pause_time(self, default: AutoSplit | float):
8789
"""Get image's pause time or fallback to the default value from spinbox."""
8890
if self.__pause_time is not None:
8991
return self.__pause_time
9092
if isinstance(default, (float, int)):
9193
return default
9294
return default.settings_dict["default_pause_time"]
9395

94-
def get_similarity_threshold(self, default: "AutoSplit | float"):
96+
def get_similarity_threshold(self, default: AutoSplit | float):
9597
"""Get image's similarity threshold or fallback to the default value from spinbox."""
9698
if self.__similarity_threshold is not None:
9799
return self.__similarity_threshold
98100
if isinstance(default, (float, int)):
99101
return default
100102
return default.settings_dict["default_similarity_threshold"]
101103

102-
def get_fps_limit(self, default: "AutoSplit"):
104+
def get_fps_limit(self, default: AutoSplit):
103105
"""Get image's fps limit or fallback to the default value from spinbox."""
104106
if self.__fps_limit != 0:
105107
return self.__fps_limit
@@ -197,7 +199,7 @@ def __read_image_bytes(self, path: str):
197199
def check_flag(self, flag: int):
198200
return self.flags & flag == flag
199201

200-
def compare_with_capture(self, default: "AutoSplit | int", capture: MatLike | None):
202+
def compare_with_capture(self, default: AutoSplit | int, capture: MatLike | None):
201203
"""
202204
Compare image with capture using image's comparison method. Falls back to combobox.
203205

src/capture_method/CaptureMethodBase.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
from typing import TYPE_CHECKING
24

35
from cv2.typing import MatLike
@@ -13,9 +15,9 @@ class CaptureMethodBase:
1315
short_description = ""
1416
description = ""
1517

16-
_autosplit_ref: "AutoSplit"
18+
_autosplit_ref: AutoSplit
1719

18-
def __init__(self, autosplit: "AutoSplit"):
20+
def __init__(self, autosplit: AutoSplit):
1921
self._autosplit_ref = autosplit
2022

2123
def reinitialize(self):

src/capture_method/DesktopDuplicationCaptureMethod.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
import sys
24

35
if sys.platform != "win32":
@@ -30,7 +32,7 @@ class DesktopDuplicationCaptureMethod(BitBltCaptureMethod):
3032
see D3DDD-Note-Laptops.md for a solution.
3133
https://www.github.com/{GITHUB_REPOSITORY}/blob/main/docs/D3DDD-Note-Laptops.md"""
3234

33-
def __init__(self, autosplit: "AutoSplit"):
35+
def __init__(self, autosplit: AutoSplit):
3436
super().__init__(autosplit)
3537
# Must not set statically as some laptops will throw an error
3638
self.desktop_duplication = d3dshot.create(capture_output="numpy")

src/capture_method/VideoCaptureDeviceCaptureMethod.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
from threading import Event, Thread
24
from typing import TYPE_CHECKING, override
35

@@ -86,7 +88,7 @@ def __read_loop(self):
8688
)
8789
)
8890

89-
def __init__(self, autosplit: "AutoSplit"):
91+
def __init__(self, autosplit: AutoSplit):
9092
super().__init__(autosplit)
9193
self.capture_device = cv2.VideoCapture(autosplit.settings_dict["capture_device_id"])
9294
self.capture_device.setExceptionMode(True)

src/capture_method/WindowsGraphicsCaptureMethod.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
import sys
24

35
if sys.platform != "win32":
@@ -41,13 +43,13 @@ class WindowsGraphicsCaptureMethod(CaptureMethodBase):
4143
Adds a yellow border on Windows 10 (not on Windows 11).
4244
Caps at around 60 FPS."""
4345

44-
size: "SizeInt32"
46+
size: SizeInt32
4547
frame_pool: Direct3D11CaptureFramePool | None = None
4648
session: GraphicsCaptureSession | None = None
4749
"""This is stored to prevent session from being garbage collected"""
4850
last_converted_frame: MatLike | None = None
4951

50-
def __init__(self, autosplit: "AutoSplit"):
52+
def __init__(self, autosplit: AutoSplit):
5153
super().__init__(autosplit)
5254
if not is_valid_hwnd(autosplit.hwnd):
5355
return

src/capture_method/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
import os
24
import sys
35
from collections import OrderedDict
@@ -148,7 +150,7 @@ def get(self, key: CaptureMethodEnum, default: object = None, /):
148150
CAPTURE_METHODS[CaptureMethodEnum.VIDEO_CAPTURE_DEVICE] = VideoCaptureDeviceCaptureMethod
149151

150152

151-
def change_capture_method(selected_capture_method: CaptureMethodEnum, autosplit: "AutoSplit"):
153+
def change_capture_method(selected_capture_method: CaptureMethodEnum, autosplit: AutoSplit):
152154
"""
153155
Seamlessly change the current capture method,
154156
initialize the new one with transferred subscriptions

src/d3d11.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# SPDX-License-Identifier: MIT
22
# Copyright (c) 2024 David Lechner <[email protected]>
3+
from __future__ import annotations
4+
35
import sys
46

57
if sys.platform != "win32":
@@ -39,7 +41,7 @@ class IUnknown(ctypes.c_void_p):
3941
AddRef = ctypes.WINFUNCTYPE(wintypes.ULONG)(1, "AddRef")
4042
Release = ctypes.WINFUNCTYPE(wintypes.ULONG)(2, "Release")
4143

42-
def query_interface(self, iid: uuid.UUID | str) -> "IUnknown":
44+
def query_interface(self, iid: uuid.UUID | str) -> IUnknown:
4345
if isinstance(iid, str):
4446
iid = uuid.UUID(iid)
4547

@@ -174,7 +176,7 @@ class D3D_FEATURE_LEVEL(enum.IntEnum):
174176

175177
def errcheck(
176178
result: int,
177-
_func: "_FuncPointer", # Actually WinFunctionType but that's an internal class
179+
_func: _FuncPointer, # Actually WinFunctionType but that's an internal class
178180
args: tuple[
179181
IUnknown | None, # IDXGIAdapter
180182
D3D_DRIVER_TYPE,

0 commit comments

Comments
 (0)