Skip to content

Commit c392b9f

Browse files
committed
Merge branch 'dev' of https://github.com/Toufool/AutoSplit into dev
2 parents 5cba9b4 + 3773f47 commit c392b9f

File tree

12 files changed

+41
-57
lines changed

12 files changed

+41
-57
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
# Ruff is version and platform sensible
4747
matrix:
4848
os: [windows-latest, ubuntu-22.04]
49-
python-version: ["3.10", "3.11", "3.12"]
49+
python-version: ["3.11", "3.12"]
5050
steps:
5151
- name: Checkout ${{ github.repository }}/${{ github.ref }}
5252
uses: actions/checkout@v4
@@ -66,7 +66,7 @@ jobs:
6666
# Pyright is version and platform sensible
6767
matrix:
6868
os: [windows-latest, ubuntu-22.04]
69-
python-version: ["3.10", "3.11", "3.12"]
69+
python-version: ["3.11", "3.12"]
7070
steps:
7171
- name: Checkout ${{ github.repository }}/${{ github.ref }}
7272
uses: actions/checkout@v4

.sonarcloud.properties

Lines changed: 0 additions & 1 deletion
This file was deleted.

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ To understand how to use AutoSplit and how it works in-depth, please read the [t
4747
- Should work on Ubuntu 20.04+ (Only tested on Ubuntu 22.04)
4848
- Wayland is not currently supported
4949
- WSL2/WSLg requires an additional Desktop Environment, external X11 server, and/or systemd
50-
- Python 3.10+ (Not required for normal use. Refer to the [build instructions](/docs/build%20instructions.md) if you'd like run the application directly in Python).
50+
- Python 3.11+ (Not required for normal use. Refer to the [build instructions](/docs/build%20instructions.md) if you'd like run the application directly in Python).
5151

5252
## Timer Integration
5353

@@ -102,6 +102,8 @@ Not a developer? You can still help through the following methods:
102102
- <https://github.com/opencv/opencv/issues/23906>
103103
- <https://github.com/pywinrt/python-winsdk/issues/11>
104104
- <https://github.com/pyinstaller/pyinstaller-hooks-contrib/issues/807>
105+
- <https://github.com/hukkin/tomli-w/pull/46>
106+
- <https://github.com/uiri/toml/issues/270>
105107
- <https://github.com/microsoft/vscode/issues/40239>
106108
- <https://github.com/microsoft/vscode/issues/168411>
107109
- <https://github.com/python/mypy/issues/6700>

docs/build instructions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
### All platforms
1515

16-
- [Python](https://www.python.org/downloads/) 3.10+.
16+
- [Python](https://www.python.org/downloads/) 3.11+.
1717
- [Node](https://nodejs.org) is optional, but required for complete linting.
1818
- Alternatively you can install the [pyright python wrapper](https://pypi.org/project/pyright/) which has a bit of an overhead delay.
1919
- [PowerShell](https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell) is used to run all the scripts.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# https://github.com/microsoft/pyright/blob/main/docs/configuration.md#sample-pyprojecttoml-file
22
[tool.pyright]
33
typeCheckingMode = "strict"
4-
pythonVersion = "3.10"
4+
pythonVersion = "3.11"
55
# Prefer `pyright: ignore`
66
enableTypeIgnoreComments = false
77

ruff.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# These configs are incompatible with ruff<0.5.7
88

99
# https://docs.astral.sh/ruff/configuration/
10-
target-version = "py310" # Change this to the oldest supported version by your application
10+
target-version = "py311" # Change this to the oldest supported version by your application
1111
line-length = 100
1212
preview = true
1313

scripts/python_build_from_source_linux.bash

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,22 @@ sudo apt update
77
sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libsqlite3-dev libreadline-dev libffi-dev curl libbz2-dev tk-dev
88

99
# Download Python binary package:
10-
wget https://www.python.org/ftp/python/3.10.13/Python-3.10.13.tgz
10+
wget https://www.python.org/ftp/python/3.11.10/Python-3.11.10.tgz
1111

1212
# Unzip the package:
13-
tar -xzf Python-3.10.13.tgz
13+
tar -xzf Python-3.11.10.tgz
1414

1515
# Execute configure script
16-
cd Python-3.10.13
16+
cd Python-3.11.10
1717
./configure --enable-optimizations --enable-shared
1818

19-
# Build Python 3.10
19+
# Build Python 3.11
2020
make -j 2
2121

22-
# Install Python 3.10
22+
# Install Python 3.11
2323
sudo make install
2424

2525
# Verify the installation
26-
python3.10 -V
26+
python3.11 -V
2727

2828
echo "If Python version did not print, you may need to stop active processes"

scripts/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ PyWinCtl>=0.0.42 # py.typed
1515
# When needed, dev builds can be found at https://download.qt.io/snapshots/ci/pyside/dev?C=M;O=D
1616
PySide6-Essentials>=6.6.0 # Python 3.12 support
1717
scipy>=1.11.2 # Python 3.12 support
18-
toml
18+
tomli-w
1919
typing-extensions>=4.4.0 # @override decorator support
2020
#
2121
# Build and compile resources

src/AutoSplitImage.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import os
2+
import tomllib
23
from enum import IntEnum, auto
34
from math import sqrt
45
from typing import TYPE_CHECKING
56

67
import cv2
78
import numpy as np
8-
import toml
99
from cv2.typing import MatLike
1010

1111
import error_messages
@@ -133,8 +133,8 @@ def __parse_text_file(self, path: str):
133133
error_messages.tesseract_missing(path)
134134
return
135135

136-
with open(path, encoding="utf-8") as f:
137-
data = toml.load(f)
136+
with open(path, mode="rb") as f:
137+
data = tomllib.load(f)
138138

139139
self.texts = [text.lower().strip() for text in data["texts"]]
140140
self.__rect = (data["left"], data["right"], data["top"], data["bottom"])

src/capture_method/__init__.py

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
import sys
33
from collections import OrderedDict
44
from dataclasses import dataclass
5-
from enum import Enum, EnumMeta, auto, unique
5+
from enum import EnumMeta, StrEnum, auto, unique
66
from itertools import starmap
7-
from typing import TYPE_CHECKING, TypedDict, cast
7+
from typing import TYPE_CHECKING, Never, TypedDict, cast
88

9-
from typing_extensions import Never, override
9+
from typing_extensions import override
1010

1111
from capture_method.CaptureMethodBase import CaptureMethodBase
1212
from capture_method.VideoCaptureDeviceCaptureMethod import VideoCaptureDeviceCaptureMethod
@@ -49,7 +49,7 @@ class Region(TypedDict):
4949
height: int
5050

5151

52-
class CaptureMethodEnumMeta(EnumMeta):
52+
class ContainerEnumMeta(EnumMeta):
5353
# Allow checking if simple string is enum
5454
@override
5555
def __contains__(cls, other: object):
@@ -61,35 +61,16 @@ def __contains__(cls, other: object):
6161

6262

6363
@unique
64-
# TODO: Try StrEnum in Python 3.11
65-
class CaptureMethodEnum(Enum, metaclass=CaptureMethodEnumMeta):
66-
# Allow TOML to save as a simple string
67-
@override
68-
def __repr__(self):
69-
return self.value
70-
71-
# Allow direct comparison with strings
72-
@override
73-
def __eq__(self, other: object):
74-
if isinstance(other, str):
75-
return self.value == other
76-
if isinstance(other, Enum):
77-
return self.value == other.value
78-
return other == self
79-
80-
# Restore hashing functionality for use in Maps
81-
@override
82-
def __hash__(self):
83-
return self.value.__hash__()
84-
64+
class CaptureMethodEnum(StrEnum, metaclass=ContainerEnumMeta):
65+
# Capitalize the string value from auto()
8566
@override
8667
@staticmethod
8768
def _generate_next_value_(
88-
name: "str | CaptureMethodEnum",
69+
name: str,
8970
start: int,
9071
count: int,
91-
last_values: list["str | CaptureMethodEnum"],
92-
):
72+
last_values: list[str],
73+
) -> str:
9374
return name
9475

9576
NONE = ""

0 commit comments

Comments
 (0)