Skip to content

Commit 4b89497

Browse files
Updated Ruff and Pyright (#321)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent a9dcd68 commit 4b89497

File tree

14 files changed

+1732
-1698
lines changed

14 files changed

+1732
-1698
lines changed

.github/workflows/lint-and-build.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ jobs:
4343
- uses: astral-sh/ruff-action@v3
4444
with:
4545
version-file: "pyproject.toml"
46-
- run: ruff format --check
46+
- run: ruff format --check --diff
47+
# Show formatting issues even if the "check" step failed
48+
if: ${{ !cancelled() }}
49+
4750
Pyright:
4851
runs-on: ${{ matrix.os }}
4952
strategy:

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ repos:
1919
- id: pretty-format-ini
2020
args: [--autofix]
2121
- repo: https://github.com/astral-sh/ruff-pre-commit
22-
rev: v0.9.6 # Must match requirements-dev.txt
22+
rev: v0.11.8 # Must match requirements-dev.txt
2323
hooks:
2424
- id: ruff
2525
args: [--fix]

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,7 @@ Not a developer? You can still help through the following methods:
100100
- <https://bugreports.qt.io/browse/PYSIDE-2541>
101101
- <https://bugreports.qt.io/browse/PYSIDE-2542>
102102
- <https://github.com/pyinstaller/pyinstaller/issues/9012>
103-
- <https://github.com/astral-sh/uv/issues/1495>
104103
- <https://github.com/opencv/opencv/issues?q=is%3Aissue+is%3Aopen+involves%3AAvasam+sort%3Areactions-%2B1-asc+>
105-
- <https://github.com/opencv/opencv/issues/18305>
106-
- <https://github.com/opencv/opencv/issues/23906>
107104
- <https://github.com/mypyc/mypyc/issues?q=sort%3Areactions-%2B1%20is%3Aissue%20is%3Aopen%20%20involves%3AAvasam%20>
108105
- <https://github.com/uiri/toml/issues/270>
109106
- <https://github.com/microsoft/vscode/issues/40239>

pyproject.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ dependencies = [
3131
"typed-D3DShot[numpy] >=1.0.1; sys_platform == 'win32'",
3232
"winrt-Windows.Foundation >=2.2.0; sys_platform == 'win32'", # Python 3.13 support
3333
"winrt-Windows.Graphics >=2.2.0; sys_platform == 'win32'", # Python 3.13 support
34-
"winrt-Windows.Graphics.Capture >=2.3.0; sys_platform == 'win32'", # Python 3.13 support
34+
"winrt-Windows.Graphics.Capture >=3.0.0; sys_platform == 'win32'", # Type hints are no longer typing.Optional by default.
3535
"winrt-Windows.Graphics.Capture.Interop >=2.3.0; sys_platform == 'win32'", # Python 3.13 support
3636
"winrt-Windows.Graphics.DirectX >=2.3.0; sys_platform == 'win32'", # Python 3.13 support
3737
"winrt-Windows.Graphics.DirectX.Direct3D11 >=2.3.0; sys_platform == 'win32'", # Python 3.13 support
@@ -51,8 +51,8 @@ dev = [
5151
#
5252
# Linters & Formatters
5353
"mypy[faster-cache] >=1.14",
54-
"pyright[nodejs] >=1.1",
55-
"ruff >=0.9.6",
54+
"pyright[nodejs] >=1.1.400", # reportPrivateImportUsage behaviour change
55+
"ruff >=0.11.8",
5656
#
5757
# Types
5858
"scipy-stubs >=1.14.1.1",
@@ -110,6 +110,8 @@ reportUnusedCallResult = "none"
110110

111111
# Exclude from scanning when running pyright
112112
exclude = [
113+
".git/", # Avoid accidentally scanning branch names ending in .py
114+
".venv*/",
113115
".venv/",
114116
# Auto generated, fails some strict pyright checks
115117
"build/",

ruff.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@
66
# Modifications to this file that are not project-specific should also be done upstream.
77

88
# https://docs.astral.sh/ruff/configuration/
9-
target-version = "py311" # Change this to the oldest supported version by your application
109
line-length = 100
1110
preview = true
12-
required-version = ">=0.9.0" # Removed ISC compatibility warning
11+
required-version = ">=0.11.0" # tool.ruff.target-version is infered from project.requires-python
1312

1413
[format]
1514
docstring-code-format = true
@@ -24,7 +23,6 @@ ignore = [
2423
"D1", # pydocstyle Missing doctring
2524
"D401", # pydocstyle: non-imperative-mood
2625
"EM", # flake8-errmsg
27-
"EXE", # flake8-executable
2826
# This is often something we can't control: https://github.com/astral-sh/ruff/issues/9497
2927
# Also false-positive with positional-only arguments: https://github.com/astral-sh/ruff/issues/3247
3028
"FBT003", # flake8-boolean-trap: boolean-positional-value-in-call

scripts/build.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#! /usr/bin/pwsh
2+
13
& "$PSScriptRoot/compile_resources.ps1"
24

35
$SupportsSplashScreen = [System.Convert]::ToBoolean($(uv run --active python -c "import _tkinter; print(hasattr(_tkinter, '__file__'))"))

scripts/compile_resources.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#! /usr/bin/pwsh
2+
13
$originalDirectory = $pwd
24
Set-Location "$PSScriptRoot/.."
35

scripts/designer.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#! /usr/bin/pwsh
2+
13
$qt6_applications_path = uv run --active python -c 'import qt6_applications; print(qt6_applications.__path__[0])'
24

35
& "$qt6_applications_path/Qt/bin/designer" `

scripts/install.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#! /usr/bin/pwsh
2+
13
# Validating user groups on Linux
24
If ($IsLinux) {
35
$groups = groups

scripts/lint.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#! /usr/bin/pwsh
2+
13
$originalDirectory = $pwd
24
Set-Location "$PSScriptRoot/.."
35
$exitCodes = 0

scripts/start.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#! /usr/bin/pwsh
2+
13
param ([string]$p1)
24
& "$PSScriptRoot/compile_resources.ps1"
35
uv run --active "$PSScriptRoot/../src/AutoSplit.py" $p1

src/capture_method/WindowsGraphicsCaptureMethod.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
WGC_NO_BORDER_MIN_BUILD = 20348
3030

3131

32-
async def convert_d3d_surface_to_software_bitmap(surface: IDirect3DSurface | None):
32+
async def convert_d3d_surface_to_software_bitmap(surface: IDirect3DSurface):
3333
return await SoftwareBitmap.create_copy_from_surface_async(surface)
3434

3535

src/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ def run_tesseract(png: bytes):
293293
@return: The recognized output string from tesseract.
294294
"""
295295
return (
296-
subprocess.Popen( # noqa: S603 # Only using known literal strings
296+
subprocess.Popen( # noqa: S603 # Only using known literal strings or shutil.which result
297297
TESSERACT_CMD, **subprocess_kwargs()
298298
)
299299
.communicate(input=png)[0]
@@ -306,7 +306,7 @@ def list_processes():
306306
return [
307307
# The first row is the process name
308308
line.split()[0]
309-
for line in subprocess.check_output( # noqa: S603 # Known input
309+
for line in subprocess.check_output(
310310
"C:/Windows/System32/tasklist.exe", text=True
311311
).splitlines()[3:] # Skip the table header lines
312312
if line

0 commit comments

Comments
 (0)