Skip to content

Commit 8888688

Browse files
committed
add missing overloads
1 parent d641d36 commit 8888688

File tree

4 files changed

+352
-12
lines changed

4 files changed

+352
-12
lines changed

ahk/_async/engine.py

Lines changed: 175 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,12 +1125,32 @@ async def set_capslock_state(
11251125
resp = await self._transport.function_call('AHKSetCapsLockState', args, blocking=blocking)
11261126
return resp
11271127

1128+
# fmt: off
1129+
@overload
1130+
async def set_volume(self, value: int, device_number: int = 1) -> None: ...
1131+
@overload
1132+
async def set_volume(self, value: int, device_number: int = 1, *, blocking: Literal[False]) -> AsyncFutureResult[None]: ...
1133+
@overload
1134+
async def set_volume(self, value: int, device_number: int = 1, *, blocking: Literal[True]) -> None: ...
1135+
@overload
1136+
async def set_volume(self, value: int, device_number: int = 1, *, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]: ...
1137+
# fmt: on
11281138
async def set_volume(
1129-
self, value: int, device_number: int = 1, blocking: bool = True
1139+
self, value: int, device_number: int = 1, *, blocking: bool = True
11301140
) -> Union[None, AsyncFutureResult[None]]:
11311141
args = [str(device_number), str(value)]
11321142
return await self._transport.function_call('AHKSetVolume', args, blocking=blocking)
11331143

1144+
# fmt: off
1145+
@overload
1146+
async def show_traytip(self, title: str, text: str, second: float = 1.0, type_id: int = 1, *, silent: bool = False, large_icon: bool = False) -> None: ...
1147+
@overload
1148+
async def show_traytip(self, title: str, text: str, second: float = 1.0, type_id: int = 1, *, silent: bool = False, large_icon: bool = False, blocking: Literal[False]) -> AsyncFutureResult[None]: ...
1149+
@overload
1150+
async def show_traytip(self, title: str, text: str, second: float = 1.0, type_id: int = 1, *, silent: bool = False, large_icon: bool = False, blocking: Literal[True]) -> None: ...
1151+
@overload
1152+
async def show_traytip(self, title: str, text: str, second: float = 1.0, type_id: int = 1, *, silent: bool = False, large_icon: bool = False, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]: ...
1153+
# fmt: on
11341154
async def show_traytip(
11351155
self,
11361156
title: str,
@@ -1146,6 +1166,16 @@ async def show_traytip(
11461166
args = [title, text, str(second), str(option)]
11471167
return await self._transport.function_call('AHKTrayTip', args, blocking=blocking)
11481168

1169+
# fmt: off
1170+
@overload
1171+
async def show_error_traytip(self, title: str, text: str, second: float = 1.0, *, silent: bool = False, large_icon: bool = False) -> None: ...
1172+
@overload
1173+
async def show_error_traytip(self, title: str, text: str, second: float = 1.0, *, silent: bool = False, large_icon: bool = False, blocking: Literal[False]) -> AsyncFutureResult[None]: ...
1174+
@overload
1175+
async def show_error_traytip(self, title: str, text: str, second: float = 1.0, *, silent: bool = False, large_icon: bool = False, blocking: Literal[True]) -> None: ...
1176+
@overload
1177+
async def show_error_traytip(self, title: str, text: str, second: float = 1.0, *, silent: bool = False, large_icon: bool = False, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]: ...
1178+
# fmt: on
11491179
async def show_error_traytip(
11501180
self,
11511181
title: str,
@@ -1160,6 +1190,16 @@ async def show_error_traytip(
11601190
title=title, text=text, second=second, type_id=3, silent=silent, large_icon=large_icon, blocking=blocking
11611191
)
11621192

1193+
# fmt: off
1194+
@overload
1195+
async def show_info_traytip(self, title: str, text: str, second: float = 1.0, *, silent: bool = False, large_icon: bool = False) -> None: ...
1196+
@overload
1197+
async def show_info_traytip(self, title: str, text: str, second: float = 1.0, *, silent: bool = False, large_icon: bool = False, blocking: Literal[False]) -> AsyncFutureResult[None]: ...
1198+
@overload
1199+
async def show_info_traytip(self, title: str, text: str, second: float = 1.0, *, silent: bool = False, large_icon: bool = False, blocking: Literal[True]) -> None: ...
1200+
@overload
1201+
async def show_info_traytip(self, title: str, text: str, second: float = 1.0, *, silent: bool = False, large_icon: bool = False, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]: ...
1202+
# fmt: on
11631203
async def show_info_traytip(
11641204
self,
11651205
title: str,
@@ -1174,6 +1214,16 @@ async def show_info_traytip(
11741214
title=title, text=text, second=second, type_id=1, silent=silent, large_icon=large_icon, blocking=blocking
11751215
)
11761216

1217+
# fmt: off
1218+
@overload
1219+
async def show_warning_traytip(self, title: str, text: str, second: float = 1.0, *, silent: bool = False, large_icon: bool = False) -> None: ...
1220+
@overload
1221+
async def show_warning_traytip(self, title: str, text: str, second: float = 1.0, *, silent: bool = False, large_icon: bool = False, blocking: Literal[False]) -> AsyncFutureResult[None]: ...
1222+
@overload
1223+
async def show_warning_traytip(self, title: str, text: str, second: float = 1.0, *, silent: bool = False, large_icon: bool = False, blocking: Literal[True]) -> None: ...
1224+
@overload
1225+
async def show_warning_traytip(self, title: str, text: str, second: float = 1.0, *, silent: bool = False, large_icon: bool = False, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]: ...
1226+
# fmt: on
11771227
async def show_warning_traytip(
11781228
self,
11791229
title: str,
@@ -1194,8 +1244,6 @@ async def show_tooltip(
11941244
x: Optional[int] = None,
11951245
y: Optional[int] = None,
11961246
which: int = 1,
1197-
*,
1198-
blocking: bool = True,
11991247
) -> None:
12001248
if which not in range(1, 21):
12011249
raise ValueError('which must be an integer between 1 and 20')
@@ -1208,29 +1256,60 @@ async def show_tooltip(
12081256
args.append(str(y))
12091257
else:
12101258
args.append('')
1211-
await self._transport.function_call('AHKShowToolTip', args, blocking=blocking)
1259+
await self._transport.function_call('AHKShowToolTip', args)
12121260

12131261
async def hide_tooltip(self, which: int = 1) -> None:
12141262
await self.show_tooltip(which=which)
12151263

1264+
# fmt: off
1265+
@overload
1266+
async def sound_beep(self, frequency: int = 523, duration: int = 150) -> None: ...
1267+
@overload
1268+
async def sound_beep(self, frequency: int = 523, duration: int = 150, *, blocking: Literal[False]) -> AsyncFutureResult[None]: ...
1269+
@overload
1270+
async def sound_beep(self, frequency: int = 523, duration: int = 150, *, blocking: Literal[True]) -> None: ...
1271+
@overload
1272+
async def sound_beep(self, frequency: int = 523, duration: int = 150, *, blocking: bool = True) -> Optional[AsyncFutureResult[None]]: ...
1273+
# fmt: on
12161274
async def sound_beep(
12171275
self, frequency: int = 523, duration: int = 150, *, blocking: bool = True
12181276
) -> Optional[AsyncFutureResult[None]]:
12191277
args = [str(frequency), str(duration)]
12201278
await self._transport.function_call('AHKSoundBeep', args, blocking=blocking)
12211279
return None
12221280

1281+
# fmt: off
1282+
@overload
1283+
async def sound_get(self, device_number: int = 1, component_type: str = 'MASTER', control_type: str = 'VOLUME') -> str: ...
1284+
@overload
1285+
async def sound_get(self, device_number: int = 1, component_type: str = 'MASTER', control_type: str = 'VOLUME', *, blocking: Literal[False]) -> AsyncFutureResult[str]: ...
1286+
@overload
1287+
async def sound_get(self, device_number: int = 1, component_type: str = 'MASTER', control_type: str = 'VOLUME', *, blocking: Literal[True]) -> str: ...
1288+
@overload
1289+
async def sound_get(self, device_number: int = 1, component_type: str = 'MASTER', control_type: str = 'VOLUME', *, blocking: bool = True) -> Union[str, AsyncFutureResult[str]]: ...
1290+
# fmt: on
12231291
async def sound_get(
12241292
self,
12251293
device_number: int = 1,
12261294
component_type: str = 'MASTER',
12271295
control_type: str = 'VOLUME',
1296+
*,
12281297
blocking: bool = True,
12291298
) -> Union[str, AsyncFutureResult[str]]:
12301299
args = [str(device_number), component_type, control_type]
12311300
return await self._transport.function_call('AHKSoundGet', args, blocking=blocking)
12321301

1233-
async def sound_play(self, filename: str, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]:
1302+
# fmt: off
1303+
@overload
1304+
async def sound_play(self, filename: str) -> None: ...
1305+
@overload
1306+
async def sound_play(self, filename: str, *, blocking: Literal[False]) -> AsyncFutureResult[None]: ...
1307+
@overload
1308+
async def sound_play(self, filename: str, *, blocking: Literal[True]) -> None: ...
1309+
@overload
1310+
async def sound_play(self, filename: str, *, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]: ...
1311+
# fmt: on
1312+
async def sound_play(self, filename: str, *, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]:
12341313
return await self._transport.function_call('AHKSoundPlay', [filename], blocking=blocking)
12351314

12361315
async def sound_set(
@@ -1239,6 +1318,7 @@ async def sound_set(
12391318
device_number: int = 1,
12401319
component_type: str = 'MASTER',
12411320
control_type: str = 'VOLUME',
1321+
*,
12421322
blocking: bool = True,
12431323
) -> Union[None, AsyncFutureResult[None]]:
12441324
args = [str(device_number), component_type, control_type, str(value)]
@@ -2648,6 +2728,16 @@ async def win_restore(
26482728
resp = await self._transport.function_call('AHKWinRestore', args, engine=self, blocking=blocking)
26492729
return resp
26502730

2731+
# fmt: off
2732+
@overload
2733+
async def win_wait(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, timeout: Optional[int] = None) -> AsyncWindow: ...
2734+
@overload
2735+
async def win_wait(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, timeout: Optional[int] = None, blocking: Literal[False]) -> AsyncFutureResult[AsyncWindow]: ...
2736+
@overload
2737+
async def win_wait(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, timeout: Optional[int] = None, blocking: Literal[True]) -> AsyncWindow: ...
2738+
@overload
2739+
async def win_wait(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, timeout: Optional[int] = None, blocking: bool = True) -> Union[AsyncWindow, AsyncFutureResult[AsyncWindow]]: ...
2740+
# fmt: on
26512741
async def win_wait(
26522742
self,
26532743
title: str = '',
@@ -2672,6 +2762,16 @@ async def win_wait(
26722762
resp = await self._transport.function_call('AHKWinWait', args, blocking=blocking, engine=self)
26732763
return resp
26742764

2765+
# fmt: off
2766+
@overload
2767+
async def win_wait_active(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, timeout: Optional[int] = None) -> AsyncWindow: ...
2768+
@overload
2769+
async def win_wait_active(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, timeout: Optional[int] = None, blocking: Literal[False]) -> AsyncFutureResult[AsyncWindow]: ...
2770+
@overload
2771+
async def win_wait_active(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, timeout: Optional[int] = None, blocking: Literal[True]) -> AsyncWindow: ...
2772+
@overload
2773+
async def win_wait_active(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, timeout: Optional[int] = None, blocking: bool = True) -> Union[AsyncWindow, AsyncFutureResult[AsyncWindow]]: ...
2774+
# fmt: on
26752775
async def win_wait_active(
26762776
self,
26772777
title: str = '',
@@ -2696,6 +2796,16 @@ async def win_wait_active(
26962796
resp = await self._transport.function_call('AHKWinWaitActive', args, blocking=blocking, engine=self)
26972797
return resp
26982798

2799+
# fmt: off
2800+
@overload
2801+
async def win_wait_not_active(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, timeout: Optional[int] = None) -> AsyncWindow: ...
2802+
@overload
2803+
async def win_wait_not_active(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, timeout: Optional[int] = None, blocking: Literal[False]) -> AsyncFutureResult[AsyncWindow]: ...
2804+
@overload
2805+
async def win_wait_not_active(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, timeout: Optional[int] = None, blocking: Literal[True]) -> AsyncWindow: ...
2806+
@overload
2807+
async def win_wait_not_active(self, title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, timeout: Optional[int] = None, blocking: bool = True) -> Union[AsyncWindow, AsyncFutureResult[AsyncWindow]]: ...
2808+
# fmt: on
26992809
async def win_wait_not_active(
27002810
self,
27012811
title: str = '',
@@ -2856,6 +2966,16 @@ async def win_move(
28562966
resp = await self._transport.function_call('AHKWinMove', args, blocking=blocking)
28572967
return resp
28582968

2969+
# fmt: off
2970+
@overload
2971+
async def get_clipboard(self) -> str: ...
2972+
@overload
2973+
async def get_clipboard(self, *, blocking: Literal[False]) -> AsyncFutureResult[str]: ...
2974+
@overload
2975+
async def get_clipboard(self, *, blocking: Literal[True]) -> str: ...
2976+
@overload
2977+
async def get_clipboard(self, *, blocking: bool = True) -> Union[str, AsyncFutureResult[str]]: ...
2978+
# fmt: on
28592979
async def get_clipboard(self, *, blocking: bool = True) -> Union[str, AsyncFutureResult[str]]:
28602980
return await self._transport.function_call('AHKGetClipboard', blocking=blocking)
28612981

@@ -2866,6 +2986,16 @@ async def set_clipboard(self, s: str, *, blocking: bool = True) -> Union[None, A
28662986
async def get_clipboard_all(self, *, blocking: bool = True) -> Union[bytes, AsyncFutureResult[bytes]]:
28672987
return await self._transport.function_call('AHKGetClipboardAll', blocking=blocking)
28682988

2989+
# fmt: off
2990+
@overload
2991+
async def set_clipboard_all(self, contents: bytes) -> None: ...
2992+
@overload
2993+
async def set_clipboard_all(self, contents: bytes, *, blocking: Literal[False]) -> AsyncFutureResult[None]: ...
2994+
@overload
2995+
async def set_clipboard_all(self, contents: bytes, *, blocking: Literal[True]) -> None: ...
2996+
@overload
2997+
async def set_clipboard_all(self, contents: bytes, *, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]: ...
2998+
# fmt: on
28692999
async def set_clipboard_all(
28703000
self, contents: bytes, *, blocking: bool = True
28713001
) -> Union[None, AsyncFutureResult[None]]:
@@ -2892,6 +3022,16 @@ def on_clipboard_change(
28923022
) -> None:
28933023
self._transport.on_clipboard_change(callback, ex_handler)
28943024

3025+
# fmt: off
3026+
@overload
3027+
async def clip_wait(self, timeout: Optional[float] = None, wait_for_any_data: bool = False) -> None: ...
3028+
@overload
3029+
async def clip_wait(self, timeout: Optional[float] = None, wait_for_any_data: bool = False, *, blocking: Literal[False]) -> AsyncFutureResult[None]: ...
3030+
@overload
3031+
async def clip_wait(self, timeout: Optional[float] = None, wait_for_any_data: bool = False, *, blocking: Literal[True]) -> None: ...
3032+
@overload
3033+
async def clip_wait(self, timeout: Optional[float] = None, wait_for_any_data: bool = False, *, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]: ...
3034+
# fmt: on
28953035
async def clip_wait(
28963036
self, timeout: Optional[float] = None, wait_for_any_data: bool = False, *, blocking: bool = True
28973037
) -> Union[None, AsyncFutureResult[None]]:
@@ -2907,12 +3047,32 @@ async def block_input(
29073047
) -> None:
29083048
await self._transport.function_call('AHKBlockInput', args=[value])
29093049

3050+
# fmt: off
3051+
@overload
3052+
async def reg_delete(self, key_name: str, value_name: Optional[str] = None) -> None: ...
3053+
@overload
3054+
async def reg_delete(self, key_name: str, value_name: Optional[str] = None, *, blocking: Literal[False]) -> Union[None, AsyncFutureResult[None]]: ...
3055+
@overload
3056+
async def reg_delete(self, key_name: str, value_name: Optional[str] = None, *, blocking: Literal[True]) -> None: ...
3057+
@overload
3058+
async def reg_delete(self, key_name: str, value_name: Optional[str] = None, *, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]: ...
3059+
# fmt: on
29103060
async def reg_delete(
29113061
self, key_name: str, value_name: Optional[str] = None, *, blocking: bool = True
29123062
) -> Union[None, AsyncFutureResult[None]]:
29133063
args = [key_name, value_name if value_name is not None else '']
29143064
return await self._transport.function_call('AHKRegDelete', args, blocking=blocking)
29153065

3066+
# fmt: off
3067+
@overload
3068+
async def reg_write(self, value_type: Literal['REG_SZ', 'REG_EXPAND_SZ', 'REG_MULTI_SZ', 'REG_DWORD', 'REG_BINARY'], key_name: str, value_name: Optional[str] = None, value: Optional[str] = None) -> None: ...
3069+
@overload
3070+
async def reg_write(self, value_type: Literal['REG_SZ', 'REG_EXPAND_SZ', 'REG_MULTI_SZ', 'REG_DWORD', 'REG_BINARY'], key_name: str, value_name: Optional[str] = None, value: Optional[str] = None, *, blocking: Literal[False]) -> AsyncFutureResult[None]: ...
3071+
@overload
3072+
async def reg_write(self, value_type: Literal['REG_SZ', 'REG_EXPAND_SZ', 'REG_MULTI_SZ', 'REG_DWORD', 'REG_BINARY'], key_name: str, value_name: Optional[str] = None, value: Optional[str] = None, *, blocking: Literal[True]) -> None: ...
3073+
@overload
3074+
async def reg_write(self, value_type: Literal['REG_SZ', 'REG_EXPAND_SZ', 'REG_MULTI_SZ', 'REG_DWORD', 'REG_BINARY'], key_name: str, value_name: Optional[str] = None, value: Optional[str] = None, *, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]: ...
3075+
# fmt: on
29163076
async def reg_write(
29173077
self,
29183078
value_type: Literal['REG_SZ', 'REG_EXPAND_SZ', 'REG_MULTI_SZ', 'REG_DWORD', 'REG_BINARY'],
@@ -2931,6 +3091,16 @@ async def reg_write(
29313091
args.append(value)
29323092
return await self._transport.function_call('AHKRegWrite', args, blocking=blocking)
29333093

3094+
# fmt: off
3095+
@overload
3096+
async def reg_read(self, key_name: str, value_name: Optional[str] = None) -> str: ...
3097+
@overload
3098+
async def reg_read(self, key_name: str, value_name: Optional[str] = None, *, blocking: Literal[False]) -> AsyncFutureResult[str]: ...
3099+
@overload
3100+
async def reg_read(self, key_name: str, value_name: Optional[str] = None, *, blocking: Literal[True]) -> str: ...
3101+
@overload
3102+
async def reg_read(self, key_name: str, value_name: Optional[str] = None, *, blocking: bool = True) -> Union[str, AsyncFutureResult[str]]: ...
3103+
# fmt: on
29343104
async def reg_read(
29353105
self, key_name: str, value_name: Optional[str] = None, *, blocking: bool = True
29363106
) -> Union[str, AsyncFutureResult[str]]:

ahk/_async/transport.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ async def function_call(self, function_name: Literal['AHKSetClipboardAll'], args
550550
@overload
551551
async def function_call(self, function_name: Literal['AHKBlockInput'], args: Optional[List[str]], *, blocking: bool = True) -> None: ...
552552
@overload
553-
async def function_call(self, function_name: Literal['AHKShowToolTip'], args: Optional[List[str]], *, blocking: bool = True) -> None: ...
553+
async def function_call(self, function_name: Literal['AHKShowToolTip'], args: Optional[List[str]]) -> None: ...
554554
@overload
555555
async def function_call(self, function_name: Literal['AHKClipWait'], args: Optional[List[str]], *, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]: ...
556556

0 commit comments

Comments
 (0)