Skip to content

Commit e1cc0ce

Browse files
committed
Refactoring. winapi__windows__ctypes/. Adding the None annotation to the return value
1 parent 84e2187 commit e1cc0ce

11 files changed

Lines changed: 18 additions & 18 deletions

File tree

‎winapi__windows__ctypes/close_ad_window_avast/close_ad_window_avast.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def get_logger():
4141

4242

4343
# TODO: не все окна являются рекламными, это может быть окно сканирования системы
44-
def close_ad():
44+
def close_ad() -> None:
4545
hwnd = win32gui.FindWindow("asw_av_popup_wndclass", None)
4646
if hwnd:
4747
log.debug("Found Avast advertising window, close it.")

‎winapi__windows__ctypes/log_window_focus__trackwindow.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@
6464
lastTime = 0
6565

6666

67-
def log(msg):
67+
def log(msg) -> None:
6868
print(msg)
6969

7070

71-
def logError(msg):
71+
def logError(msg) -> None:
7272
print(msg, file=sys.stderr)
7373

7474

@@ -129,7 +129,7 @@ def getProcessFilename(processID):
129129
kernel32.CloseHandle(hProcess)
130130

131131

132-
def callback(hWinEventHook, event, hwnd, idObject, idChild, dwEventThread, dwmsEventTime):
132+
def callback(hWinEventHook, event, hwnd, idObject, idChild, dwEventThread, dwmsEventTime) -> None:
133133
global lastTime
134134
length = user32.GetWindowTextLengthW(hwnd)
135135
title = ctypes.create_unicode_buffer(length + 1)
@@ -169,7 +169,7 @@ def setHook(WinEventProc, eventType):
169169
)
170170

171171

172-
def main():
172+
def main() -> None:
173173
ole32.CoInitialize(0)
174174

175175
WinEventProc = WinEventProcType(callback)

‎winapi__windows__ctypes/set_wallpaper_on_win/set_wallpaper.py‎

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

1515

16-
def set_wallpaper(file_name):
16+
def set_wallpaper(file_name) -> None:
1717
key = win32api.RegOpenKeyEx(
1818
win32con.HKEY_CURRENT_USER, "Control Panel\\Desktop", 0, win32con.KEY_SET_VALUE
1919
)

‎winapi__windows__ctypes/set_wallpaper_on_win/set_wallpaper_with_ctypes.py‎

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

1515

16-
def set_wallpaper_with_ctypes(file_name):
16+
def set_wallpaper_with_ctypes(file_name) -> None:
1717
# This code is based on the following two links
1818
# http://mail.python.org/pipermail/python-win32/2005-January/002893.html
1919
# http://code.activestate.com/recipes/435877-change-the-wallpaper-under-windows/

‎winapi__windows__ctypes/winapi_SetThreadExecutionState__preventing system entering sleep or turning off display/gui.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
w.setWindowTitle("Preventing entering sleep or turning off the display")
1616
w.setLayout(qtw.QVBoxLayout())
1717

18-
def button_clicked(checked):
18+
def button_clicked(checked) -> None:
1919
if checked:
2020
button.setText("On")
2121
preventing_on()

‎winapi__windows__ctypes/winapi_SetThreadExecutionState__preventing system entering sleep or turning off display/main.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818
SetThreadExecutionState = ctypes.windll.kernel32.SetThreadExecutionState
1919

2020

21-
def preventing_on():
21+
def preventing_on() -> None:
2222
# Television recording is beginning. Enable away mode and prevent the sleep idle time-out.
2323
SetThreadExecutionState(
2424
ES_CONTINUOUS | ES_SYSTEM_REQUIRED | ES_AWAYMODE_REQUIRED | ES_DISPLAY_REQUIRED
2525
)
2626

2727

28-
def preventing_off():
28+
def preventing_off() -> None:
2929
# Clear EXECUTION_STATE flags to disable away mode and allow the system to idle to sleep normally.
3030
SetThreadExecutionState(ES_CONTINUOUS)
3131

‎winapi__windows__ctypes/winapi__GetTextLastError.py‎

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

1515

16-
def GetTextLastError(error_code=None):
16+
def GetTextLastError(error_code=None) -> str:
1717
"""
1818
Функция возвращает текстовое описание ошибки.
1919
Если не передавать код ошибки, будет возвращаться описание ошибки из GetLastError().

‎winapi__windows__ctypes/winapi__close_child_windows.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import win32con
1616

1717

18-
def all_ok(hwnd, param):
18+
def all_ok(hwnd, param) -> bool:
1919
text = win32gui.GetWindowText(hwnd)
2020
class_name = win32gui.GetClassName(hwnd)
2121
print(f'#{hwnd:0>8x} "{text}": {class_name}')
@@ -27,7 +27,7 @@ def all_ok(hwnd, param):
2727
return True
2828

2929

30-
def close_toolbars():
30+
def close_toolbars() -> None:
3131
hwnd = win32gui.FindWindow("Notepad++", None)
3232
if not hwnd:
3333
print('Window "Notepad++" not found!')

‎winapi__windows__ctypes/winapi__process_list.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class PROCESSENTRY32(ctypes.Structure):
3232
("szExeFile", ctypes.c_char * 260),
3333
]
3434

35-
def __str__(self):
35+
def __str__(self) -> str:
3636
return (
3737
"szExeFile={} "
3838
"th32ProcessID={} "

‎winapi__windows__ctypes/windows__toast_balloontip_notifications/notifications.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
class WindowsBalloonTip:
2323
@staticmethod
24-
def balloon_tip(title, msg, duration=5, icon_path_name=None):
24+
def balloon_tip(title, msg, duration=5, icon_path_name=None) -> None:
2525
message_map = {
2626
win32con.WM_DESTROY: WindowsBalloonTip.on_destroy,
2727
}
@@ -90,7 +90,7 @@ def balloon_tip(title, msg, duration=5, icon_path_name=None):
9090
UnregisterClass(wc.lpszClassName, None)
9191

9292
@staticmethod
93-
def on_destroy(hwnd, msg, wparam, lparam):
93+
def on_destroy(hwnd, msg, wparam, lparam) -> None:
9494
nid = (hwnd, 0)
9595
Shell_NotifyIcon(NIM_DELETE, nid)
9696
PostQuitMessage(0) # Terminate the app.

0 commit comments

Comments
 (0)