Skip to content

Commit

Permalink
Update all linting tools
Browse files Browse the repository at this point in the history
  • Loading branch information
Avasam committed Aug 2, 2024
1 parent 413afca commit e61be26
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 17 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ repos:
args: [--fix=lf]
- id: check-case-conflict
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.13.0
rev: v2.14.0
hooks:
- id: pretty-format-ini
args: [--autofix]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.4.7" # Must match requirements-dev.txt
rev: "v0.5.6" # Must match requirements-dev.txt
hooks:
- id: ruff
args: [--fix]
- repo: https://github.com/hhatto/autopep8
rev: "v2.2.0" # Must match requirements-dev.txt
rev: "v2.3.1" # Must match requirements-dev.txt
hooks:
- id: autopep8
- repo: https://github.com/asottile/add-trailing-comma
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ ignore = [
# Specific to this project
###
"D205", # Not all docstrings have a short description + desrciption
# TODO: Consider for more complete doc
"DOC201", # docstring-extraneous-returns
"DOC501", # docstring-missing-exception
# We have some Pascal case module names
"N999", # pep8-naming: Invalid module name
# Print are used as debug logs
Expand Down
2 changes: 1 addition & 1 deletion scripts/lint.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ else {
Write-Host "`Ruff passed" -ForegroundColor Green
}

$pyrightVersion = '1.1.364' # Change this if latest has issues
$pyrightVersion = 'latest' # Change this if latest has issues
Write-Host "`nRunning Pyright $pyrightVersion ..."
$Env:PYRIGHT_PYTHON_FORCE_VERSION = $pyrightVersion
npx -y pyright@$pyrightVersion src/
Expand Down
4 changes: 2 additions & 2 deletions scripts/requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
#
# Linters & Formatters
add-trailing-comma>=3.1.0 # Must match .pre-commit-config.yaml
autopep8>=2.0.4 # Must match .pre-commit-config.yaml
ruff>=0.3.2 # New checks # Must match .pre-commit-config.yaml
autopep8>=2.3.1 # Must match .pre-commit-config.yaml
ruff>=0.5.6 # New checks # Must match .pre-commit-config.yaml
#
# Types
types-D3DShot ; sys_platform == 'win32'
Expand Down
4 changes: 2 additions & 2 deletions src/AutoSplitImage.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
COMPARISON_RESIZE_HEIGHT = 240
COMPARISON_RESIZE = (COMPARISON_RESIZE_WIDTH, COMPARISON_RESIZE_HEIGHT)
COMPARISON_RESIZE_AREA = COMPARISON_RESIZE_WIDTH * COMPARISON_RESIZE_HEIGHT
MASK_LOWER_BOUND = np.array([0, 0, 0, 1], dtype="uint8")
MASK_UPPER_BOUND = np.array([MAXBYTE, MAXBYTE, MAXBYTE, MAXBYTE], dtype="uint8")
MASK_LOWER_BOUND = np.array([0, 0, 0, 1], dtype=np.uint8)
MASK_UPPER_BOUND = np.array([MAXBYTE, MAXBYTE, MAXBYTE, MAXBYTE], dtype=np.uint8)
START_KEYWORD = "start_auto_splitter"
RESET_KEYWORD = "reset"

Expand Down
4 changes: 2 additions & 2 deletions src/capture_method/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ class Region(TypedDict):
class CaptureMethodEnumMeta(EnumMeta):
# Allow checking if simple string is enum
@override
def __contains__(self, other: object):
def __contains__(cls, other: object):
try:
self(other)
cls(other)
except ValueError:
return False
return True
Expand Down
2 changes: 1 addition & 1 deletion src/menu_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def __init__(self, autosplit: "AutoSplit", *, check_on_open: bool):
@override
def run(self):
try:
with urlopen(f"https://api.github.com/repos/{GITHUB_REPOSITORY}/releases/latest", timeout=30) as response: # noqa: S310
with urlopen(f"https://api.github.com/repos/{GITHUB_REPOSITORY}/releases/latest", timeout=30) as response:
json_response: dict[str, str] = json.loads(response.read())
latest_version = json_response["name"].split("v")[1]
self._autosplit_ref.update_checker_widget_signal.emit(latest_version, self.check_on_open)
Expand Down
2 changes: 1 addition & 1 deletion src/split_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def flags_from_filename(filename: str):
def __pop_image_type(split_image: list[AutoSplitImage], image_type: ImageType):
for image in split_image:
if image.image_type == image_type:
split_image.remove(image)
split_image.remove(image) # noqa: B909 # False-positive: https://github.com/astral-sh/ruff/issues/12640
return image

return None
Expand Down
7 changes: 4 additions & 3 deletions src/user_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import error_messages
from capture_method import CAPTURE_METHODS, CaptureMethodEnum, Region, change_capture_method
from gen import design
from hotkeys import HOTKEYS, remove_all_hotkeys, set_hotkey
from hotkeys import HOTKEYS, Hotkey, remove_all_hotkeys, set_hotkey
from menu_bar import open_settings
from utils import auto_split_directory

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

remove_all_hotkeys()
if not autosplit.is_auto_controlled:
for hotkey, hotkey_name in [(hotkey, f"{hotkey}_hotkey") for hotkey in HOTKEYS]:
for hotkey, hotkey_name in ((hotkey, f"{hotkey}_hotkey") for hotkey in HOTKEYS):
hotkey_value = autosplit.settings_dict.get(hotkey_name)
if hotkey_value:
set_hotkey(autosplit, hotkey, hotkey_value)
# cast caused by a regression in pyright 1.1.365
set_hotkey(autosplit, cast(Hotkey, hotkey), hotkey_value)

Check failure on line 157 in src/user_profile.py

View workflow job for this annotation

GitHub Actions / Pyright (windows-latest, 3.10)

Unnecessary "cast" call; type is already "Literal['split', 'reset', 'skip_split', 'undo_split', 'pause', 'screenshot', 'toggle_auto_reset_image']" (reportUnnecessaryCast)

Check failure on line 157 in src/user_profile.py

View workflow job for this annotation

GitHub Actions / Pyright (windows-latest, 3.11)

Unnecessary "cast" call; type is already "Literal['split', 'reset', 'skip_split', 'undo_split', 'pause', 'screenshot', 'toggle_auto_reset_image']" (reportUnnecessaryCast)

Check failure on line 157 in src/user_profile.py

View workflow job for this annotation

GitHub Actions / Pyright (windows-latest, 3.12)

Unnecessary "cast" call; type is already "Literal['split', 'reset', 'skip_split', 'undo_split', 'pause', 'screenshot', 'toggle_auto_reset_image']" (reportUnnecessaryCast)

Check failure on line 157 in src/user_profile.py

View workflow job for this annotation

GitHub Actions / Pyright (ubuntu-22.04, 3.10)

Unnecessary "cast" call; type is already "Literal['split', 'reset', 'skip_split', 'undo_split', 'pause', 'screenshot', 'toggle_auto_reset_image']" (reportUnnecessaryCast)

Check failure on line 157 in src/user_profile.py

View workflow job for this annotation

GitHub Actions / Pyright (ubuntu-22.04, 3.11)

Unnecessary "cast" call; type is already "Literal['split', 'reset', 'skip_split', 'undo_split', 'pause', 'screenshot', 'toggle_auto_reset_image']" (reportUnnecessaryCast)

Check failure on line 157 in src/user_profile.py

View workflow job for this annotation

GitHub Actions / Pyright (ubuntu-22.04, 3.12)

Unnecessary "cast" call; type is already "Literal['split', 'reset', 'skip_split', 'undo_split', 'pause', 'screenshot', 'toggle_auto_reset_image']" (reportUnnecessaryCast)

change_capture_method(cast(CaptureMethodEnum, autosplit.settings_dict["capture_method"]), autosplit)
if autosplit.settings_dict["capture_method"] != CaptureMethodEnum.VIDEO_CAPTURE_DEVICE:
Expand Down
4 changes: 2 additions & 2 deletions src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,8 @@ def run_tesseract(png: bytes):
@return: The recognized output string from tesseract.
"""
return (
subprocess
.Popen(TESSERACT_CMD, **subprocess_kwargs()) # noqa: S603 # Only using known literal strings
subprocess # noqa: S603 # Only using known literal strings
.Popen(TESSERACT_CMD, **subprocess_kwargs())
.communicate(input=png)[0]
.decode()
)
Expand Down

0 comments on commit e61be26

Please sign in to comment.