Skip to content

Commit e61be26

Browse files
committed
Update all linting tools
1 parent 413afca commit e61be26

File tree

10 files changed

+21
-17
lines changed

10 files changed

+21
-17
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ repos:
1212
args: [--fix=lf]
1313
- id: check-case-conflict
1414
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
15-
rev: v2.13.0
15+
rev: v2.14.0
1616
hooks:
1717
- id: pretty-format-ini
1818
args: [--autofix]
1919
- repo: https://github.com/astral-sh/ruff-pre-commit
20-
rev: "v0.4.7" # Must match requirements-dev.txt
20+
rev: "v0.5.6" # Must match requirements-dev.txt
2121
hooks:
2222
- id: ruff
2323
args: [--fix]
2424
- repo: https://github.com/hhatto/autopep8
25-
rev: "v2.2.0" # Must match requirements-dev.txt
25+
rev: "v2.3.1" # Must match requirements-dev.txt
2626
hooks:
2727
- id: autopep8
2828
- repo: https://github.com/asottile/add-trailing-comma

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ ignore = [
5353
# Specific to this project
5454
###
5555
"D205", # Not all docstrings have a short description + desrciption
56+
# TODO: Consider for more complete doc
57+
"DOC201", # docstring-extraneous-returns
58+
"DOC501", # docstring-missing-exception
5659
# We have some Pascal case module names
5760
"N999", # pep8-naming: Invalid module name
5861
# Print are used as debug logs

scripts/lint.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ else {
1616
Write-Host "`Ruff passed" -ForegroundColor Green
1717
}
1818

19-
$pyrightVersion = '1.1.364' # Change this if latest has issues
19+
$pyrightVersion = 'latest' # Change this if latest has issues
2020
Write-Host "`nRunning Pyright $pyrightVersion ..."
2121
$Env:PYRIGHT_PYTHON_FORCE_VERSION = $pyrightVersion
2222
npx -y pyright@$pyrightVersion src/

scripts/requirements-dev.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
#
1414
# Linters & Formatters
1515
add-trailing-comma>=3.1.0 # Must match .pre-commit-config.yaml
16-
autopep8>=2.0.4 # Must match .pre-commit-config.yaml
17-
ruff>=0.3.2 # New checks # Must match .pre-commit-config.yaml
16+
autopep8>=2.3.1 # Must match .pre-commit-config.yaml
17+
ruff>=0.5.6 # New checks # Must match .pre-commit-config.yaml
1818
#
1919
# Types
2020
types-D3DShot ; sys_platform == 'win32'

src/AutoSplitImage.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
COMPARISON_RESIZE_HEIGHT = 240
2222
COMPARISON_RESIZE = (COMPARISON_RESIZE_WIDTH, COMPARISON_RESIZE_HEIGHT)
2323
COMPARISON_RESIZE_AREA = COMPARISON_RESIZE_WIDTH * COMPARISON_RESIZE_HEIGHT
24-
MASK_LOWER_BOUND = np.array([0, 0, 0, 1], dtype="uint8")
25-
MASK_UPPER_BOUND = np.array([MAXBYTE, MAXBYTE, MAXBYTE, MAXBYTE], dtype="uint8")
24+
MASK_LOWER_BOUND = np.array([0, 0, 0, 1], dtype=np.uint8)
25+
MASK_UPPER_BOUND = np.array([MAXBYTE, MAXBYTE, MAXBYTE, MAXBYTE], dtype=np.uint8)
2626
START_KEYWORD = "start_auto_splitter"
2727
RESET_KEYWORD = "reset"
2828

src/capture_method/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ class Region(TypedDict):
4444
class CaptureMethodEnumMeta(EnumMeta):
4545
# Allow checking if simple string is enum
4646
@override
47-
def __contains__(self, other: object):
47+
def __contains__(cls, other: object):
4848
try:
49-
self(other)
49+
cls(other)
5050
except ValueError:
5151
return False
5252
return True

src/menu_bar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def __init__(self, autosplit: "AutoSplit", *, check_on_open: bool):
106106
@override
107107
def run(self):
108108
try:
109-
with urlopen(f"https://api.github.com/repos/{GITHUB_REPOSITORY}/releases/latest", timeout=30) as response: # noqa: S310
109+
with urlopen(f"https://api.github.com/repos/{GITHUB_REPOSITORY}/releases/latest", timeout=30) as response:
110110
json_response: dict[str, str] = json.loads(response.read())
111111
latest_version = json_response["name"].split("v")[1]
112112
self._autosplit_ref.update_checker_widget_signal.emit(latest_version, self.check_on_open)

src/split_parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ def flags_from_filename(filename: str):
167167
def __pop_image_type(split_image: list[AutoSplitImage], image_type: ImageType):
168168
for image in split_image:
169169
if image.image_type == image_type:
170-
split_image.remove(image)
170+
split_image.remove(image) # noqa: B909 # False-positive: https://github.com/astral-sh/ruff/issues/12640
171171
return image
172172

173173
return None

src/user_profile.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import error_messages
1010
from capture_method import CAPTURE_METHODS, CaptureMethodEnum, Region, change_capture_method
1111
from gen import design
12-
from hotkeys import HOTKEYS, remove_all_hotkeys, set_hotkey
12+
from hotkeys import HOTKEYS, Hotkey, remove_all_hotkeys, set_hotkey
1313
from menu_bar import open_settings
1414
from utils import auto_split_directory
1515

@@ -150,10 +150,11 @@ def __load_settings_from_file(autosplit: "AutoSplit", load_settings_file_path: s
150150

151151
remove_all_hotkeys()
152152
if not autosplit.is_auto_controlled:
153-
for hotkey, hotkey_name in [(hotkey, f"{hotkey}_hotkey") for hotkey in HOTKEYS]:
153+
for hotkey, hotkey_name in ((hotkey, f"{hotkey}_hotkey") for hotkey in HOTKEYS):
154154
hotkey_value = autosplit.settings_dict.get(hotkey_name)
155155
if hotkey_value:
156-
set_hotkey(autosplit, hotkey, hotkey_value)
156+
# cast caused by a regression in pyright 1.1.365
157+
set_hotkey(autosplit, cast(Hotkey, hotkey), hotkey_value)
157158

158159
change_capture_method(cast(CaptureMethodEnum, autosplit.settings_dict["capture_method"]), autosplit)
159160
if autosplit.settings_dict["capture_method"] != CaptureMethodEnum.VIDEO_CAPTURE_DEVICE:

src/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,8 @@ def run_tesseract(png: bytes):
321321
@return: The recognized output string from tesseract.
322322
"""
323323
return (
324-
subprocess
325-
.Popen(TESSERACT_CMD, **subprocess_kwargs()) # noqa: S603 # Only using known literal strings
324+
subprocess # noqa: S603 # Only using known literal strings
325+
.Popen(TESSERACT_CMD, **subprocess_kwargs())
326326
.communicate(input=png)[0]
327327
.decode()
328328
)

0 commit comments

Comments
 (0)