Skip to content

Commit 33a49c6

Browse files
committed
Linted pyi files
1 parent 0b267a6 commit 33a49c6

27 files changed

+21774
-75399
lines changed

.flake8

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,20 @@ exclude=src/gen/
88
; Allow imports at the bottom of file
99
ignore=W503,Y015,E402
1010
per-file-ignores=
11+
; Uses "pass" for empty body
12+
; Default arguments
13+
; Doesn't work when using /** below for some reasons
14+
; win32typing.pyi: Y010,Y011,
15+
; win32gui.pyi: Y010,Y011,
16+
;
1117
; Quotes
12-
__init__.pyi:Q000
18+
; undefined name 'Unknown'
19+
; allow ... on same line as def
20+
; Naming stuff
21+
;
22+
; Q002 quote docstring for cv2-stubs
23+
typings/**: Q000,F821,E704,N8,E501,Y010,Y011,Q002
24+
1325
; PyQt methods
1426
ignore-names=closeEvent,paintEvent,keyPressEvent,mousePressEvent,mouseMoveEvent,mouseReleaseEvent
1527
; McCabe max-complexity is also taken care of by Pylint and doesn't fail the build there

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ jobs:
6464
pip install -r "scripts/requirements.txt"
6565
- run: scripts/compile_resources.bat
6666
- name: Analysing the code with ${{ job.name }}
67-
run: pylint --reports=y --output-format=colorized $(git ls-files '**/*.py*')
67+
run: pylint --reports=y --output-format=colorized $(git ls-files '**/*.py')
6868
Flake8:
6969
runs-on: windows-latest
7070
strategy:

PyInstaller/hooks/hook-cv2.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
# ------------------------------------------------------------------
2-
# Copyright (c) 2020 PyInstaller Development Team.
3-
#
4-
# This file is distributed under the terms of the GNU General Public
5-
# License (version 2.0 or later).
6-
#
7-
# The full license is available in LICENSE.GPL.txt, distributed with
8-
# this software.
9-
#
10-
# SPDX-License-Identifier: GPL-2.0-or-later
11-
# ------------------------------------------------------------------
12-
# https://github.com/pyinstaller/pyinstaller-hooks-contrib/blob/master/src/_pyinstaller_hooks_contrib/hooks/stdhooks/hook-cv2.py
1+
"""
2+
Copyright (c) 2020 PyInstaller Development Team.
3+
4+
This file is distributed under the terms of the GNU General Public
5+
License (version 2.0 or later).
6+
7+
The full license is available in LICENSE.GPL.txt, distributed with
8+
this software.
9+
10+
SPDX-License-Identifier: GPL-2.0-or-later
11+
12+
https://github.com/pyinstaller/pyinstaller-hooks-contrib/blob/master/src/_pyinstaller_hooks_contrib/hooks/stdhooks/hook-cv2.py
13+
"""
1314

1415
from PyInstaller.utils.hooks import collect_dynamic_libs, collect_data_files
1516

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ This program can be used to automatically start, split, and reset your preferred
6767

6868
### Comparison Method
6969

70-
- There are three comparison methods to choose from: L2 Norm, Histograms, and pHash.
70+
- There are three comparison methods to choose from: L2 Norm, Histograms, and Perceptual Hash (or pHash).
7171
- L2 Norm: This method should be fine to use for most cases. it finds the difference between each pixel, squares it, and sums it over the entire image and takes the square root. This is very fast but is a problem if your image is high frequency. Any translational movement or rotation can cause similarity to be very different.
7272
- Histograms: An explanation on Histograms comparison can be found [here](https://mpatacchiola.github.io/blog/2016/11/12/the-simplest-classifier-histogram-intersection.html). This is a great method to use if you are using several masked images.
73-
- pHash: An explanation on pHash comparison can be found [here](http://www.hackerfactor.com/blog/index.php?/archives/432-Looks-Like-It.html). It is highly recommended to NOT use pHash if you use masked images. It is very inaccurate.
73+
- Perceptual Hash: An explanation on pHash comparison can be found [here](http://www.hackerfactor.com/blog/index.php?/archives/432-Looks-Like-It.html). It is highly recommended to NOT use pHash if you use masked images. It is very inaccurate.
7474

7575
### Full Content Rendering
7676

pyproject.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ reportImplicitStringConcatenation=true
2323
ignore = [
2424
# Auto generated
2525
"src/gen/",
26-
# We expect stub files to be incomplete or contain useless statements as they're external
26+
# We expect stub files to be incomplete or contain useless statements
2727
"typings/",
2828
]
2929
reportMissingTypeStubs = "information"
@@ -42,7 +42,7 @@ reportUnknownMemberType = "none"
4242
# https://pylint.pycqa.org/en/latest/technical_reference/features.html
4343
[tool.pylint.REPORTS]
4444
# Just like default but any error will make drop to 9 or less
45-
evaluation = "10.0 - error - ((float(warning * 10 + refactor + convention) / statement) * 10)"
45+
evaluation = "10.0 - error - ((float((warning + convention) * 10 + refactor ) / statement) * 10)"
4646
[tool.pylint.MASTER]
4747
fail-under = 9.0
4848
# https://pylint.pycqa.org/en/latest/technical_reference/extensions.html
@@ -73,8 +73,8 @@ load-plugins = [
7373
ignore-paths = [
7474
# Auto generated
7575
"^src/gen/.*$",
76-
# We expect stub files to be incomplete or contain useless statements as they're external
77-
"^typings/.*$",
76+
# We expect stub files to be incomplete or contain useless statements
77+
"^.*\\.pyi$",
7878
]
7979
# No need to mention the fixmes
8080
disable = ["fixme"]

res/settings.ui

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@
192192
</item>
193193
<item>
194194
<property name="text">
195-
<string>pHash</string>
195+
<string>Perceptual Hash</string>
196196
</property>
197197
</item>
198198
</widget>

scripts/lint.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ if ($LastExitCode -gt 0) {
1313
}
1414

1515
Write-Host "`nRunning Pylint..."
16-
pylint --score=n --output-format=colorized $(git ls-files '**/*.py*')
16+
pylint --score=n --output-format=colorized $(git ls-files '**/*.py')
1717
$exitCodes += $LastExitCode
1818
if ($LastExitCode -gt 0) {
1919
Write-Host "`Pylint failed ($LastExitCode)" -ForegroundColor Red

scripts/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ requests
2525
# Linting and Types
2626
bandit
2727
flake8
28+
flake8-pyi
2829
flake8-quotes
2930
pylint
3031
pywin32-stubs

src/AutoSplit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ def __take_screenshot(self):
398398

399399
# save and open image
400400
cv2.imwrite(screenshot_path, capture)
401-
os.startfile(screenshot_path)
401+
os.startfile(screenshot_path) # nosec
402402

403403
def __check_fps(self):
404404
self.fps_value_label.clear()

src/compare.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def compare_template(source: cv2.ndarray, capture: cv2.ndarray, mask: Optional[c
8080

8181
def compare_phash(source: cv2.ndarray, capture: cv2.ndarray, mask: Optional[cv2.ndarray] = None):
8282
"""
83-
Compares the pHash of the two given images and returns the similarity between the two.
83+
Compares the Perceptual Hash of the two given images and returns the similarity between the two.
8484
8585
@param source: Image of any given shape as a numpy array
8686
@param capture: Image of any given shape as a numpy array

typings/cv2-stubs/__init__.pyi

Lines changed: 734 additions & 81 deletions
Large diffs are not rendered by default.

typings/imagehash/__init__.pyi

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
"""
22
This type stub file was generated by pyright.
33
"""
4-
from __future__ import absolute_import, division, print_function, annotations
5-
from PIL import Image, ImageFilter
6-
import numpy
4+
from __future__ import absolute_import, division, print_function
5+
from PIL import Image
76

8-
__version__ = ...
7+
__version__: str = ...
98

109

1110
class ImageHash:

0 commit comments

Comments
 (0)