Skip to content

Commit

Permalink
Merge pull request #263 from Toufool/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Avasam authored Dec 3, 2023
2 parents 377ebde + de64398 commit af8ab61
Show file tree
Hide file tree
Showing 38 changed files with 3,447 additions and 5,248 deletions.
28 changes: 14 additions & 14 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
root = true

[*]
end_of_line = crlf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 2

[*.py]
indent_size = 4

[*.ui]
indent_size = 1
root = true

[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 2

[*.py]
indent_size = 4

[*.ui]
indent_size = 1
23 changes: 8 additions & 15 deletions .github/workflows/lint-and-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,18 @@ env:
GITHUB_HEAD_REPOSITORY: ${{ github.event.pull_request.head.repo.full_name }}
GITHUB_EXCLUDE_BUILD_NUMBER: ${{ inputs.excludeBuildNumber }}

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
ruff:
runs-on: windows-latest
strategy:
fail-fast: false
# Ruff is version and platform sensible
matrix:
python-version: ["3.9", "3.10", "3.11"]
python-version: ["3.10", "3.11", "3.12"]
steps:
- name: Checkout ${{ github.repository }}/${{ github.ref }}
uses: actions/checkout@v3
Expand All @@ -54,25 +58,13 @@ jobs:
- run: scripts/install.ps1
shell: pwsh
- run: ruff check .
add-trailing-comma:
runs-on: windows-latest
steps:
- name: Checkout ${{ github.repository }}/${{ github.ref }}
uses: actions/checkout@v3
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: "3.11"
- run: pip install add-trailing-comma
- name: Analysing the code with add-trailing-comma
run: add-trailing-comma $(git ls-files '**.py*')
Pyright:
runs-on: windows-latest
strategy:
fail-fast: false
# Pyright is version and platform sensible
matrix:
python-version: ["3.9", "3.10", "3.11"]
python-version: ["3.10", "3.11", "3.12"]
steps:
- name: Checkout ${{ github.repository }}/${{ github.ref }}
uses: actions/checkout@v3
Expand All @@ -88,13 +80,14 @@ jobs:
uses: jakebailey/pyright-action@v1
with:
working-directory: src/
python-version: ${{ matrix.python-version }}
Build:
runs-on: windows-latest
strategy:
fail-fast: false
# Only the Python version we plan on shipping matters.
matrix:
python-version: ["3.11"]
python-version: ["3.11", "3.12"]
steps:
- name: Checkout ${{ github.repository }}/${{ github.ref }}
uses: actions/checkout@v3
Expand Down
15 changes: 8 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: pretty-format-json
exclude: ".vscode/.*" # Exclude jsonc
Expand All @@ -12,26 +12,27 @@ repos:
args: [--fix=crlf]
- id: check-case-conflict
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.9.0
rev: v2.11.0
hooks:
- id: pretty-format-ini
args: [--autofix]
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.0.276" # Must match requirements-dev.txt
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.1.6" # Must match requirements-dev.txt
hooks:
- id: ruff
args: [--fix]
- repo: https://github.com/pre-commit/mirrors-autopep8
rev: "v2.0.2" # Must match requirements-dev.txt
- repo: https://github.com/hhatto/autopep8
rev: "v2.0.4" # Must match requirements-dev.txt
hooks:
- id: autopep8
- repo: https://github.com/asottile/add-trailing-comma
rev: v3.0.0 # Must match requirements-dev.txt
rev: v3.1.0 # Must match requirements-dev.txt
hooks:
- id: add-trailing-comma

ci:
autoupdate_branch: dev
autoupdate_schedule: monthly
skip:
# Ignore until Linux support. We don't want lf everywhere yet
# And crlf fails on CI because pre-commit runs on linux
Expand Down
2 changes: 1 addition & 1 deletion .sonarcloud.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sonar.python.version=3.9, 3.10, 3.11
sonar.python.version=3.10, 3.11, 3.12
19 changes: 12 additions & 7 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
"files.trimTrailingWhitespace": true,
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true,
"files.eol": "\n",
"editor.comments.insertSpace": true,
"editor.insertSpaces": true,
"editor.detectIndentation": false,
"editor.tabSize": 2,
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll": true,
"source.fixAll.unusedImports": false,
"source.fixAll.convertImportFormat": true,
// Let dedicated linter (Ruff) organize imports
"source.organizeImports": false,
},
"emeraldwalk.runonsave": {
Expand Down Expand Up @@ -63,7 +63,7 @@
"editor.defaultFormatter": "vscode.json-language-features",
},
"[python]": {
// Ruff is not yet a formatter: https://github.com/charliermarsh/ruff/issues/1904
// Ruff as a formatter doesn't fully satisfy our needs yet: https://github.com/astral-sh/ruff/discussions/7310
"editor.defaultFormatter": "ms-python.autopep8",
"editor.tabSize": 4,
"editor.rulers": [
Expand All @@ -80,23 +80,28 @@
"--config-file=mypy.ini",
],
"python.terminal.activateEnvironment": true,
// python.analysis is Pylance (pyright) configurations
"python.analysis.fixAll": [
"source.convertImportFormat"
// Explicitly omiting "source.unusedImports", can be annoying when commenting code for debugging
],
// Important to follow the config in pyrightconfig.json
"python.analysis.useLibraryCodeForTypes": false,
"python.analysis.diagnosticMode": "workspace",
"python.linting.enabled": true,
"ruff.importStrategy": "fromEnvironment",
// Use the Ruff extension instead
"isort.check": false,
// linting/formatting options deprecated, use dedicated extensions instead
// https://github.com/microsoft/vscode-python/wiki/Migration-to-Python-Tools-Extensions
"python.linting.enabled": false,
"python.linting.banditEnabled": false,
"python.linting.flake8Enabled": false,
"python.linting.prospectorEnabled": false,
"python.linting.pycodestyleEnabled": false,
"python.linting.pylamaEnabled": false,
"python.linting.pylintEnabled": false,
// Use the autopep8 extension instead
"python.formatting.provider": "none",
// Use Pyright/Pylance instead
"python.linting.mypyEnabled": false,
"python.formatting.provider": "none",
"powershell.codeFormatting.pipelineIndentationStyle": "IncreaseIndentationForFirstPipeline",
"powershell.codeFormatting.autoCorrectAliases": true,
"powershell.codeFormatting.trimWhitespaceAroundPipe": true,
Expand Down
2 changes: 0 additions & 2 deletions PyInstaller/hooks/hook-requests.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import annotations

from PyInstaller.utils.hooks import collect_data_files

# Get the cacert.pem
Expand Down
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@
[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=Avasam_AutoSplit&metric=reliability_rating)](https://sonarcloud.io/dashboard?id=Avasam_AutoSplit)
[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=Avasam_AutoSplit&metric=security_rating)](https://sonarcloud.io/dashboard?id=Avasam_AutoSplit)
[![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=Avasam_AutoSplit&metric=code_smells)](https://sonarcloud.io/summary/new_code?id=Avasam_AutoSplit)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=Avasam_AutoSplit&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=Avasam_AutoSplit)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=Avasam_AutoSplit&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=Avasam_AutoSplit)
[![SemVer](https://badgen.net/badge/_/SemVer%20compliant/grey?label)](https://semver.org/)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![autopep8](https://badgen.net/badge/code%20style/autopep8/blue)](https://github.com/hhatto/autopep8)
[![Checked with pyright](https://microsoft.github.io/pyright/img/pyright_badge.svg)](https://microsoft.github.io/pyright/)
[![Checked with mypy](https://www.mypy-lang.org/static/mypy_badge.svg)](https://mypy-lang.org/)

Easy to use image comparison based auto splitter for speedrunning on console or PC.

Expand All @@ -25,14 +29,14 @@ This program can be used to automatically start, split, and reset your preferred
### Compatibility

- Windows 10 and 11.
- Python 3.9+ (Not requried for normal use. Refer to the [build instructions](/docs/build%20instructions.md) if you'd like run the application directly in Python).
- 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).

## OPTIONS

#### Split Image Folder

- Supported image file types: .png, .jpg, .jpeg, .bmp, and [more](https://docs.opencv.org/3.0-beta/modules/imgcodecs/doc/reading_and_writing_images.html#imread).
- Images can be any size.
- Supported image file types: PNG, JPEG, bitmaps, WebP, and [more](https://docs.opencv.org/4.8.0/d4/da8/group__imgcodecs.html#imread).
- Images can be any size and ratio.
- Images are matched in alphanumerical order.
- Recommended filenaming convention: `001_SplitName.png, 002_SplitName.png, 003_SplitName.png`...
- Custom split image settings are handled in the filename. See how [here](#custom-split-image-settings).
Expand Down Expand Up @@ -79,7 +83,7 @@ This program can be used to automatically start, split, and reset your preferred
Duplicates the desktop using Direct3D.
It can record OpenGL and Hardware Accelerated windows.
About 10-15x slower than BitBlt. Not affected by window size.
overlapping windows will show up and can't record across displays.
Overlapping windows will show up and can't record across displays.
This option may not be available for hybrid GPU laptops, see [D3DDD-Note-Laptops.md](/docs/D3DDD-Note-Laptops.md) for a solution.
- **Force Full Content Rendering** (very slow, can affect rendering)
Uses BitBlt behind the scene, but passes a special flag to PrintWindow to force rendering the entire desktop.
Expand Down
2 changes: 1 addition & 1 deletion docs/build instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

### All platforms

- [Python](https://www.python.org/downloads/) 3.9+.
- [Python](https://www.python.org/downloads/) 3.10+.
- [Node](https://nodejs.org) is optional, but required for complete linting.
- Alternatively you can install the [pyright python wrapper](https://pypi.org/project/pyright/) which has a bit of an overhead delay.
- [PowerShell](https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell)
Expand Down
43 changes: 24 additions & 19 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# https://beta.ruff.rs/docs/configuration
# https://docs.astral.sh/ruff/configuration/
[tool.ruff]
target-version = "py39"
target-version = "py310"
line-length = 120
select = ["ALL", "NURSERY"]
extend-fixable = ["NURSERY"]
# https://beta.ruff.rs/docs/rules
select = ["ALL"]
preview = true
# https://docs.astral.sh/ruff/rules/
ignore = [
###
# Not needed or wanted
Expand All @@ -21,6 +21,8 @@ ignore = [
"ERA001", # eradicate: commented-out-code
# contextlib.suppress is roughly 3x slower than try/except
"SIM105", # flake8-simplify: use-contextlib-suppress
# Negative performance impact
"UP038", # non-pep604-isinstance
# Checked by type-checker (pyright)
"ANN", # flake-annotations
"PGH003", # blanket-type-ignore
Expand All @@ -34,7 +36,7 @@ ignore = [
"TD001", # flake8-todos: invalid-todo-tag

###
# These should be warnings (https://github.com/charliermarsh/ruff/issues/1256)
# These should be warnings (https://github.com/astral-sh/ruff/issues/1256 & https://github.com/astral-sh/ruff/issues/1774)
###
"FIX", # flake8-fixme
# Not all TODOs are worth an issue, this would be better as a warning
Expand All @@ -56,45 +58,44 @@ ignore = [
# Python 3.11, introduced "zero cost" exception handling
"PERF203", # try-except-in-loop

### FIXME/TODO (no warnings in Ruff yet: https://github.com/charliermarsh/ruff/issues/1256):
"CPY001",
"PTH",
### FIXME/TODO (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",
"EXE", # flake8-executable
]

[tool.ruff.per-file-ignores]
"typings/**/*.pyi" = [
"F811", # Re-exports false positives
"F821", # https://github.com/charliermarsh/ruff/issues/3011
"F821", # https://github.com/astral-sh/ruff/issues/3011
# The following can't be controlled for external libraries:
"A", # Shadowing builtin names
"ICN001", # unconventional-import-alias
"N8", # Naming conventions
"PLR0904", # Too many public methods
"PLR0913", # Argument count
"PLW3201", # misspelled dunder method name
"PYI042", # CamelCase TypeAlias
]

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

# https://beta.ruff.rs/docs/settings/#isort
# https://docs.astral.sh/ruff/settings/#isort
[tool.ruff.isort]
combine-as-imports = true
split-on-trailing-comma = false
required-imports = ["from __future__ import annotations"]
# Unlike isort, Ruff only counts relative imports as local-folder by default for know.
# https://github.com/charliermarsh/ruff/issues/2419
# https://github.com/charliermarsh/ruff/issues/3115
# https://github.com/astral-sh/ruff/issues/3115
known-local-folder = [
"AutoControlledThread",
"AutoSplit",
"AutoSplitImage",
"capture_method",
"compare",
"error_messages",
"error_messages",
"gen",
"hotkeys",
"menu_bar",
Expand All @@ -104,7 +105,7 @@ known-local-folder = [
"utils",
]

# https://beta.ruff.rs/docs/settings/#mccabe
# https://docs.astral.sh/ruff/settings/#mccabe
[tool.ruff.mccabe]
# Hard limit, arbitrary to 4 bytes
max-complexity = 31
Expand All @@ -127,7 +128,10 @@ ignore = [
"E124", # Closing bracket may not match multi-line method invocation style (enforced by add-trailing-comma)
"E70", # Allow ... on same line as def
# Autofixed by Ruff
# Check for the "Fix" flag https://beta.ruff.rs/docs/rules/#pycodestyle-e-w
# Check for the "Fix" flag https://docs.astral.sh/ruff/rules/#pycodestyle-e-w
"E20", # whitespace-after-* & whitespace-before-*
"E211", # whitespace-before-parameters
"E231", # missing-whitespace
"E401", # I001: unsorted-imports
"E71", # Comparisons
"E731", # lambda-assignment
Expand All @@ -138,6 +142,7 @@ ignore = [
# https://github.com/microsoft/pyright/blob/main/docs/configuration.md#sample-pyprojecttoml-file
[tool.pyright]
typeCheckingMode = "strict"
pythonVersion = "3.10"
# Prefer `pyright: ignore`
enableTypeIgnoreComments = false
# Extra strict
Expand Down
Loading

0 comments on commit af8ab61

Please sign in to comment.