Skip to content

Commit bbee09e

Browse files
committed
Merge pull request #17 from Avasam/use-pywin32-stubs-fork
Use pywin32 stubs fork
2 parents 3d89b50 + eecb751 commit bbee09e

25 files changed

+153
-66985
lines changed

.flake8

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,25 @@
11
[flake8]
22
color=always
33
max-line-length=120
4-
; Auto generated
5-
exclude=src/gen/
6-
; Linebreak before binary operator
7-
; Allow default value other than "..."
8-
; Allow imports at the bottom of file
9-
ignore=W503,Y015,E402
4+
exclude=
5+
src/gen/, ; Auto generated
6+
typings/cv2-stubs/__init__.pyi, ; External existing stub
7+
ignore=
8+
W503, ; Linebreak before binary operator
9+
Y015, ; Allow default value other than "..."
10+
E402, ; Allow imports at the bottom of file
11+
Y026, ; Not using typing_extensions
1012
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-
;
17-
; Quotes
18-
; undefined name 'Unknown'
1913
; 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
14+
; ???
15+
; Docstrings in type stubs
16+
; Function bodys contain other than just ... (eg: raise)
17+
; Single quote docstrings
18+
typings/cv2-stubs/__init__.pyi: Q000,N8, E704,Y021,Y010,Q002
2419

20+
; Quotes
21+
; Naming conventions can't be controlled for external libraries
22+
__init__.pyi: Q000,N8
2523
; PyQt methods
2624
ignore-names=closeEvent,paintEvent,keyPressEvent,mousePressEvent,mouseMoveEvent,mouseReleaseEvent
2725
; McCabe max-complexity is also taken care of by Pylint and doesn't fail the build there

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ dist/
1919

2020
# Dev settings
2121
*.pkl
22+
settings.toml

.vscode/settings.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@
5858
"python.linting.pylintCategorySeverity.refactor": "Warning",
5959
"python.linting.flake8Enabled": true,
6060
"python.linting.flake8CategorySeverity.E": "Warning",
61+
// Pyflakes
62+
"python.linting.flake8CategorySeverity.F": "Warning",
63+
// PEP8 Naming convention
64+
"python.linting.flake8CategorySeverity.N": "Warning",
65+
// PYI
66+
"python.linting.flake8CategorySeverity.Y": "Warning",
6167
// PyRight obsoletes mypy
6268
"python.linting.mypyEnabled": false,
6369
// Is already wrapped by Flake8, prospector and pylama

pyproject.toml

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,23 @@ aggressive = 3
1616
pythonPlatform = "Windows"
1717
typeCheckingMode = "strict"
1818
# Extra strict
19-
reportPropertyTypeMismatch=true
20-
reportUninitializedInstanceVariable=true
21-
reportCallInDefaultInitializer=true
22-
reportImplicitStringConcatenation=true
19+
reportImplicitStringConcatenation="error"
20+
reportCallInDefaultInitializer="error"
21+
reportMissingSuperCall="none" # False positives on base classes
22+
reportPropertyTypeMismatch="error"
23+
reportUninitializedInstanceVariable="error"
24+
reportUnnecessaryTypeIgnoreComment="error"
25+
reportUnusedCallResult="none"
2326
ignore = [
2427
# Auto generated
2528
"src/gen/",
2629
# We expect stub files to be incomplete or contain useless statements
2730
"typings/",
2831
]
29-
reportMissingTypeStubs = "information"
32+
reportMissingTypeStubs = "warning"
3033
# False positives with TYPE_CHECKING
3134
reportImportCycles = "information"
32-
# False positives with PyQt .connect. pylint(no-member) works instead
35+
# False positives with PyQt .connect . pylint(no-member) works instead
3336
reportFunctionMemberAccess = "none"
3437
# Extra runtime safety
3538
reportUnnecessaryComparison = "warning"
@@ -70,11 +73,17 @@ load-plugins = [
7073
# "pylint.extensions.comparison_placement",
7174
# "pylint.extensions.for_any_all",
7275
]
73-
ignore-paths = [
74-
# Auto generated
75-
"^src/gen/.*$",
76+
# Auto generated (doesn't work)
77+
ignore-paths = ["src/gen/.*"]
7678
# We expect stub files to be incomplete or contain useless statements
77-
"^.*\\.pyi$",
79+
ignore-patterns = [
80+
".*\\.pyi",
81+
# Auto generated
82+
"about.py",
83+
"design.py",
84+
"resources_rc.py",
85+
"settings.py",
86+
"update_checker.py",
7887
]
7988
# No need to mention the fixmes
8089
disable = ["fixme"]

scripts/requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ bandit
2727
flake8
2828
flake8-pyi
2929
flake8-quotes
30-
pylint
31-
pywin32-stubs
30+
pylint>=2.13
31+
git+https://github.com/Avasam/pywin32-stubs.git#egg=pywin32-stubs # https://github.com/kaluluosi/pywin32-stubs/pull/4
3232
simplejson
3333
types-simplejson>=3.17.2
3434
types-requests

src/AutoSplit.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -760,8 +760,7 @@ def __get_capture_for_comparison(self):
760760
if capture is None:
761761
# Try to recover by using the window name
762762
self.live_image.setText("Trying to recover window...")
763-
# https://github.com/kaluluosi/pywin32-stubs/issues/7
764-
hwnd = win32gui.FindWindow(None, self.settings_dict["captured_window_title"]) # type: ignore
763+
hwnd = win32gui.FindWindow(None, self.settings_dict["captured_window_title"])
765764
# Don't fallback to desktop
766765
if hwnd:
767766
self.hwnd = hwnd

src/capture_windows.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import win32ui
1414
import pywintypes
1515
from win32 import win32gui
16-
from win32typing import PyCBitmap, PyCDC
1716

1817
# This is an undocumented nFlag value for PrintWindow
1918
PW_RENDERFULLCONTENT = 0x00000002
@@ -40,16 +39,15 @@ def capture_region(hwnd: int, selection: Region, print_window: bool):
4039

4140
# If the window closes while it's being manipulated, it could cause a crash
4241
try:
43-
window_dc: int = win32gui.GetWindowDC(hwnd)
44-
# https://github.com/kaluluosi/pywin32-stubs/issues/6
45-
dc_object: PyCDC = win32ui.CreateDCFromHandle(window_dc) # type: ignore
42+
window_dc = win32gui.GetWindowDC(hwnd)
43+
dc_object = win32ui.CreateDCFromHandle(window_dc)
4644

4745
# Causes a 10-15x performance drop. But allows recording hardware accelerated windows
4846
if print_window:
4947
ctypes.windll.user32.PrintWindow(hwnd, dc_object.GetSafeHdc(), PW_RENDERFULLCONTENT)
5048

5149
compatible_dc = dc_object.CreateCompatibleDC()
52-
bitmap: PyCBitmap = win32ui.CreateBitmap()
50+
bitmap = win32ui.CreateBitmap()
5351
bitmap.CreateCompatibleBitmap(dc_object, selection.width, selection.height)
5452
compatible_dc.SelectObject(bitmap)
5553
compatible_dc.BitBlt((0, 0),

src/settings_file.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,14 +167,14 @@ def __load_settings_from_file(autosplit: AutoSplit, load_settings_file_path: str
167167
autosplit.settings_dict["force_print_window"] = settings[20]
168168

169169
if autosplit.settings_dict["captured_window_title"]:
170-
# https://github.com/kaluluosi/pywin32-stubs/issues/7
171-
hwnd = win32gui.FindWindow(None, autosplit.settings_dict["captured_window_title"]) # type: ignore
170+
hwnd = win32gui.FindWindow(None, autosplit.settings_dict["captured_window_title"])
172171
if hwnd:
173172
autosplit.hwnd = hwnd
174173
else:
175-
autosplit.live_image.setText("Reload settings after opening"
176-
+ f'\n"{autosplit.settings_dict["captured_window_title"]}"'
177-
+ "\nto automatically load Capture Region")
174+
autosplit.live_image.setText(
175+
"Reload settings after opening"
176+
+ f'\n"{autosplit.settings_dict["captured_window_title"]}"'
177+
+ "\nto automatically load Capture Region")
178178
return True
179179

180180

typings/PyInstaller/utils/hooks/__init__.pyi

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
"""
1+
""" # noqa: Y021
22
This type stub file was generated by pyright.
33
"""
4-
from typing import Any, Literal, Optional, Union
5-
from collections.abc import Callable
4+
from typing import Any, Literal, Optional, Union, Callable
65

76
logger = ...
87
PY_IGNORE_EXTENSIONS: set
@@ -85,11 +84,7 @@ def is_module_or_submodule(name, mod_or_submod):
8584
...
8685

8786

88-
PY_DYLIB_PATTERNS = [
89-
"*.dll",
90-
"*.dylib",
91-
"lib*.so",
92-
]
87+
PY_DYLIB_PATTERNS: str
9388

9489

9590
def collect_dynamic_libs(package: str, destdir: Optional[str] = ...) -> list[tuple[str, str]]:

typings/imagehash/__init__.pyi

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,16 @@
1-
"""
1+
""" # noqa: Y021
22
This type stub file was generated by pyright.
33
"""
4-
from __future__ import absolute_import, division, print_function
4+
from __future__ import absolute_import, division, print_function, annotations
55
from PIL import Image
66

7-
__version__: str = ...
7+
__version__: str
88

99

1010
class ImageHash:
1111
def __init__(self, binary_array) -> None:
1212
...
1313

14-
def __str__(self) -> str:
15-
...
16-
17-
def __repr__(self) -> str:
18-
...
19-
2014
def __sub__(self, other: ImageHash) -> int:
2115
...
2216

@@ -89,13 +83,7 @@ class ImageMultiHash:
8983
def __hash__(self) -> int:
9084
...
9185

92-
def __str__(self) -> str:
93-
...
94-
95-
def __repr__(self) -> str:
96-
...
97-
98-
def hash_diff(self, other_hash, hamming_cutoff=..., bit_error_rate=...) -> tuple[int, Unknown | int]:
86+
def hash_diff(self, other_hash, hamming_cutoff=..., bit_error_rate=...) -> tuple[int, int]:
9987
...
10088

10189
def matches(self, other_hash, region_cutoff=..., hamming_cutoff=..., bit_error_rate=...):

0 commit comments

Comments
 (0)