Skip to content

Commit

Permalink
Linted pyi files
Browse files Browse the repository at this point in the history
  • Loading branch information
Avasam committed Dec 16, 2021
1 parent 0b267a6 commit 33a49c6
Show file tree
Hide file tree
Showing 27 changed files with 21,774 additions and 75,399 deletions.
14 changes: 13 additions & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,20 @@ exclude=src/gen/
; Allow imports at the bottom of file
ignore=W503,Y015,E402
per-file-ignores=
; Uses "pass" for empty body
; Default arguments
; Doesn't work when using /** below for some reasons
; win32typing.pyi: Y010,Y011,
; win32gui.pyi: Y010,Y011,
;
; Quotes
__init__.pyi:Q000
; undefined name 'Unknown'
; allow ... on same line as def
; Naming stuff
;
; Q002 quote docstring for cv2-stubs
typings/**: Q000,F821,E704,N8,E501,Y010,Y011,Q002

; PyQt methods
ignore-names=closeEvent,paintEvent,keyPressEvent,mousePressEvent,mouseMoveEvent,mouseReleaseEvent
; McCabe max-complexity is also taken care of by Pylint and doesn't fail the build there
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint-and-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
pip install -r "scripts/requirements.txt"
- run: scripts/compile_resources.bat
- name: Analysing the code with ${{ job.name }}
run: pylint --reports=y --output-format=colorized $(git ls-files '**/*.py*')
run: pylint --reports=y --output-format=colorized $(git ls-files '**/*.py')
Flake8:
runs-on: windows-latest
strategy:
Expand Down
25 changes: 13 additions & 12 deletions PyInstaller/hooks/hook-cv2.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
# ------------------------------------------------------------------
# Copyright (c) 2020 PyInstaller Development Team.
#
# This file is distributed under the terms of the GNU General Public
# License (version 2.0 or later).
#
# The full license is available in LICENSE.GPL.txt, distributed with
# this software.
#
# SPDX-License-Identifier: GPL-2.0-or-later
# ------------------------------------------------------------------
# https://github.com/pyinstaller/pyinstaller-hooks-contrib/blob/master/src/_pyinstaller_hooks_contrib/hooks/stdhooks/hook-cv2.py
"""
Copyright (c) 2020 PyInstaller Development Team.
This file is distributed under the terms of the GNU General Public
License (version 2.0 or later).
The full license is available in LICENSE.GPL.txt, distributed with
this software.
SPDX-License-Identifier: GPL-2.0-or-later
https://github.com/pyinstaller/pyinstaller-hooks-contrib/blob/master/src/_pyinstaller_hooks_contrib/hooks/stdhooks/hook-cv2.py
"""

from PyInstaller.utils.hooks import collect_dynamic_libs, collect_data_files

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ This program can be used to automatically start, split, and reset your preferred

### Comparison Method

- There are three comparison methods to choose from: L2 Norm, Histograms, and pHash.
- There are three comparison methods to choose from: L2 Norm, Histograms, and Perceptual Hash (or pHash).
- 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.
- 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.
- 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.
- 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.

### Full Content Rendering

Expand Down
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ reportImplicitStringConcatenation=true
ignore = [
# Auto generated
"src/gen/",
# We expect stub files to be incomplete or contain useless statements as they're external
# We expect stub files to be incomplete or contain useless statements
"typings/",
]
reportMissingTypeStubs = "information"
Expand All @@ -42,7 +42,7 @@ reportUnknownMemberType = "none"
# https://pylint.pycqa.org/en/latest/technical_reference/features.html
[tool.pylint.REPORTS]
# Just like default but any error will make drop to 9 or less
evaluation = "10.0 - error - ((float(warning * 10 + refactor + convention) / statement) * 10)"
evaluation = "10.0 - error - ((float((warning + convention) * 10 + refactor ) / statement) * 10)"
[tool.pylint.MASTER]
fail-under = 9.0
# https://pylint.pycqa.org/en/latest/technical_reference/extensions.html
Expand Down Expand Up @@ -73,8 +73,8 @@ load-plugins = [
ignore-paths = [
# Auto generated
"^src/gen/.*$",
# We expect stub files to be incomplete or contain useless statements as they're external
"^typings/.*$",
# We expect stub files to be incomplete or contain useless statements
"^.*\\.pyi$",
]
# No need to mention the fixmes
disable = ["fixme"]
Expand Down
2 changes: 1 addition & 1 deletion res/settings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@
</item>
<item>
<property name="text">
<string>pHash</string>
<string>Perceptual Hash</string>
</property>
</item>
</widget>
Expand Down
2 changes: 1 addition & 1 deletion scripts/lint.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ if ($LastExitCode -gt 0) {
}

Write-Host "`nRunning Pylint..."
pylint --score=n --output-format=colorized $(git ls-files '**/*.py*')
pylint --score=n --output-format=colorized $(git ls-files '**/*.py')
$exitCodes += $LastExitCode
if ($LastExitCode -gt 0) {
Write-Host "`Pylint failed ($LastExitCode)" -ForegroundColor Red
Expand Down
1 change: 1 addition & 0 deletions scripts/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ requests
# Linting and Types
bandit
flake8
flake8-pyi
flake8-quotes
pylint
pywin32-stubs
Expand Down
2 changes: 1 addition & 1 deletion src/AutoSplit.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ def __take_screenshot(self):

# save and open image
cv2.imwrite(screenshot_path, capture)
os.startfile(screenshot_path)
os.startfile(screenshot_path) # nosec

def __check_fps(self):
self.fps_value_label.clear()
Expand Down
2 changes: 1 addition & 1 deletion src/compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def compare_template(source: cv2.ndarray, capture: cv2.ndarray, mask: Optional[c

def compare_phash(source: cv2.ndarray, capture: cv2.ndarray, mask: Optional[cv2.ndarray] = None):
"""
Compares the pHash of the two given images and returns the similarity between the two.
Compares the Perceptual Hash of the two given images and returns the similarity between the two.
@param source: Image of any given shape as a numpy array
@param capture: Image of any given shape as a numpy array
Expand Down
815 changes: 734 additions & 81 deletions typings/cv2-stubs/__init__.pyi

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions typings/imagehash/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
"""
This type stub file was generated by pyright.
"""
from __future__ import absolute_import, division, print_function, annotations
from PIL import Image, ImageFilter
import numpy
from __future__ import absolute_import, division, print_function
from PIL import Image

__version__ = ...
__version__: str = ...


class ImageHash:
Expand Down
Loading

0 comments on commit 33a49c6

Please sign in to comment.