Skip to content

Commit

Permalink
Test dependencies and linting update
Browse files Browse the repository at this point in the history
  • Loading branch information
Avasam committed Mar 9, 2024
1 parent 099443c commit b1625b9
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ repos:
- id: pretty-format-ini
args: [--autofix]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.1.14" # Must match requirements-dev.txt
rev: "v0.3.2" # Must match requirements-dev.txt
hooks:
- id: ruff
args: [--fix]
Expand Down
18 changes: 11 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
[tool.ruff]
target-version = "py310"
line-length = 120
select = ["ALL"]
preview = true

[tool.ruff.lint]
select = ["ALL"]
# https://docs.astral.sh/ruff/rules/
ignore = [
###
Expand Down Expand Up @@ -58,14 +60,15 @@ ignore = [
# Python 3.11, introduced "zero cost" exception handling
"PERF203", # try-except-in-loop

### FIXME/TODO (no warnings in Ruff yet: https://github.com/astral-sh/ruff/issues/1256 & https://github.com/astral-sh/ruff/issues/1774):
### FIXME/TODO: I'd normally set them as temporarily warnings, but no warnings in Ruff yet:
### https://github.com/astral-sh/ruff/issues/1256 & https://github.com/astral-sh/ruff/issues/1774):
"CPY001", # flake8-copyright
"PTH", # flake8-use-pathlib
# Ignore until linux support
"EXE", # flake8-executable
]

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
"typings/**/*.pyi" = [
"F811", # Re-exports false positives
"F821", # https://github.com/astral-sh/ruff/issues/3011
Expand All @@ -82,11 +85,11 @@ ignore = [
]

# https://docs.astral.sh/ruff/settings/#flake8-implicit-str-concat
[tool.ruff.flake8-implicit-str-concat]
[tool.ruff.lint.flake8-implicit-str-concat]
allow-multiline = false

# https://docs.astral.sh/ruff/settings/#isort
[tool.ruff.isort]
[tool.ruff.lint.isort]
combine-as-imports = true
split-on-trailing-comma = false
# Unlike isort, Ruff only counts relative imports as local-folder by default for know.
Expand All @@ -108,13 +111,13 @@ known-local-folder = [
]

# https://docs.astral.sh/ruff/settings/#mccabe
[tool.ruff.mccabe]
[tool.ruff.lint.mccabe]
# Hard limit, arbitrary to 4 bytes
max-complexity = 31
# Arbitrary to 2 bytes, same as SonarLint
# max-complexity = 15

[tool.ruff.pylint]
[tool.ruff.lint.pylint]
# Arbitrary to 1 byte, same as SonarLint
max-args = 7
# At least same as max-complexity
Expand All @@ -133,6 +136,7 @@ ignore = [
# Autofixed by Ruff
# Check for the "Fix" flag https://docs.astral.sh/ruff/rules/#pycodestyle-e-w
"E2", # Whitespace
"E3", # Blank lines
"E703", # useless-semicolon
"E71", # Statement (comparisons)
"E731", # lambda-assignment
Expand Down
7 changes: 5 additions & 2 deletions scripts/install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ If ($IsLinux) {
}
# Ensures installation tools are up to date. This also aliases pip to pip3 on MacOS.
&"$python" -m pip install wheel pip setuptools --upgrade
# Upgrading QT to 6.6.2 w/o first uninstalling shiboken6 can lead to issues
# https://bugreports.qt.io/browse/PYSIDE-2616?focusedId=777285&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-777285
&"$python" -m pip uninstall shiboken6
&"$python" -m pip install -r "$PSScriptRoot/requirements$dev.txt" --upgrade
# These libraries install extra requirements we don't want
# Open suggestion for support in requirements files: https://github.com/pypa/pip/issues/9948 & https://github.com/pypa/pip/pull/10837
Expand Down Expand Up @@ -72,11 +75,11 @@ If ($IsLinux) {
Set-Content "$libPath/QtWidgets.pyi"
}
# Uninstall optional dependencies if PyAutoGUI or D3DShot was installed outside this script
# pyscreeze -> pyscreenshot -> mss deps call SetProcessDpiAwareness, used to be installed on Windows
# PyScreeze -> pyscreenshot -> mss deps call SetProcessDpiAwareness, used to be installed on Windows
# Pillow, pygetwindow, pymsgbox, pytweening, MouseInfo are picked up by PySide6
# (also --exclude from build script, but more consistent with unfrozen run)
&"$python" -m pip uninstall pyscreenshot mss pygetwindow pymsgbox pytweening MouseInfo -y
If ($IsWindows) { &"$python" -m pip uninstall pyscreeze Pillow -y }
If ($IsWindows) { &"$python" -m pip uninstall PyScreeze Pillow -y }

# Don't compile resources on the Build CI job as it'll do so in build script
If ($dev) {
Expand Down
4 changes: 2 additions & 2 deletions scripts/requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# 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.1.14 # New checks # Must match .pre-commit-config.yaml
ruff>=0.3.2 # New checks # Must match .pre-commit-config.yaml
#
# Types
types-D3DShot ; sys_platform == 'win32'
Expand All @@ -23,5 +23,5 @@ types-psutil
types-PyAutoGUI
types-pyinstaller
types-python-xlib ; sys_platform == 'linux'
types-pywin32>=306.0.0.8 ; sys_platform == 'win32'
types-pywin32>=306.0.0.20240130 ; sys_platform == 'win32'
types-toml
2 changes: 1 addition & 1 deletion scripts/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ winsdk>=1.0.0b10 ; sys_platform == 'win32' # Python 3.12 support
# D3DShot # See install.ps1
#
# Linux-only dependencies
pyscreeze ; sys_platform == 'linux'
PyScreeze ; sys_platform == 'linux'
python-xlib ; sys_platform == 'linux'
3 changes: 1 addition & 2 deletions src/AutoSplit.py
Original file line number Diff line number Diff line change
Expand Up @@ -943,8 +943,7 @@ def set_preview_image(qlabel: QLabel, image: MatLike | None):
capture = image

qimage = QtGui.QImage(

Check failure on line 945 in src/AutoSplit.py

View workflow job for this annotation

GitHub Actions / Pyright (ubuntu-22.04, 3.10)

No overloads for "__init__" match the provided arguments (reportCallIssue)

Check failure on line 945 in src/AutoSplit.py

View workflow job for this annotation

GitHub Actions / Pyright (ubuntu-22.04, 3.11)

No overloads for "__init__" match the provided arguments (reportCallIssue)
# https://bugreports.qt.io/browse/PYSIDE-2476
capture.data, # pyright: ignore[reportCallIssue, reportArgumentType]
capture.data,

Check failure on line 946 in src/AutoSplit.py

View workflow job for this annotation

GitHub Actions / Pyright (ubuntu-22.04, 3.10)

Argument of type "memoryview" cannot be assigned to parameter "data" of type "bytes" in function "__init__"   "memoryview" is incompatible with "bytes"   Set disableBytesTypePromotions to false to enable type promotion behavior for "bytearray" and "memoryview" (reportArgumentType)

Check failure on line 946 in src/AutoSplit.py

View workflow job for this annotation

GitHub Actions / Pyright (ubuntu-22.04, 3.11)

Argument of type "memoryview" cannot be assigned to parameter "data" of type "bytes" in function "__init__"   "memoryview" is incompatible with "bytes"   Set disableBytesTypePromotions to false to enable type promotion behavior for "bytearray" and "memoryview" (reportArgumentType)
width,
height,
width * channels,
Expand Down
8 changes: 3 additions & 5 deletions src/capture_method/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# pyright: reportUnknownMemberType=false
# Complete type for PIL.features.check_feature upstream
import asyncio
import os
import sys
Expand Down Expand Up @@ -120,7 +118,7 @@ def __getitem__( # type:ignore[override] # pyright: ignore[reportIncompatibleMe
return super().__getitem__(__key)

@override
def get(self, key: CaptureMethodEnum, __default: object = None):
def get(self, key: CaptureMethodEnum, default: object = None, /):
"""
Returns the `CaptureMethodBase` subclass for `CaptureMethodEnum` if `CaptureMethodEnum` is available,
else defaults to the first available `CaptureMethodEnum`.
Expand Down Expand Up @@ -165,8 +163,8 @@ def get(self, key: CaptureMethodEnum, __default: object = None):

def change_capture_method(selected_capture_method: CaptureMethodEnum, autosplit: "AutoSplit"):
"""
Seemlessly change the current capture method,
initialize the new one with transfered subscriptions
Seamlessly change the current capture method,
initialize the new one with transferred subscriptions
and update UI as needed.
"""
autosplit.capture_method.close()
Expand Down
8 changes: 0 additions & 8 deletions typings/scipy/fft/_realtransforms.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ from numpy.typing import NDArray

__all__ = ["dct", "dctn", "dst", "dstn", "idct", "idctn", "idst", "idstn"]


def dctn(
x,
type=2,
Expand All @@ -17,7 +16,6 @@ def dctn(
orthogonalize=None,
): ...


def idctn(
x,
type=2,
Expand All @@ -29,7 +27,6 @@ def idctn(
orthogonalize=None,
): ...


def dstn(
x,
type=2,
Expand All @@ -41,7 +38,6 @@ def dstn(
orthogonalize=None,
): ...


def idstn(
x,
type=2,
Expand All @@ -53,7 +49,6 @@ def idstn(
orthogonalize=None,
): ...


def dct(
x: NDArray[generic],
type: int = 2,
Expand All @@ -65,7 +60,6 @@ def dct(
orthogonalize: Incomplete | None = None,
) -> NDArray[float64]: ...


def idct(
x,
type=2,
Expand All @@ -77,7 +71,6 @@ def idct(
orthogonalize=None,
): ...


def dst(
x,
type=2,
Expand All @@ -89,7 +82,6 @@ def dst(
orthogonalize=None,
): ...


def idst(
x,
type=2,
Expand Down

0 comments on commit b1625b9

Please sign in to comment.