From 808249e5f72754bc3b221e18abd024d4b92731fa Mon Sep 17 00:00:00 2001 From: Avasam Date: Wed, 31 Aug 2022 02:39:05 -0400 Subject: [PATCH 01/13] Added pyautogui stubs --- pyrightconfig.stricter.json | 3 +- stubs/PyAutoGUI/METADATA.toml | 4 + stubs/PyAutoGUI/pyautogui/__init__.pyi | 233 ++++++++++++++++++ stubs/PyAutoGUI/pyautogui/_pyautogui_java.pyi | 0 stubs/PyAutoGUI/pyautogui/_pyautogui_osx.pyi | 2 + stubs/PyAutoGUI/pyautogui/_pyautogui_win.pyi | 28 +++ stubs/PyAutoGUI/pyautogui/_pyautogui_x11.pyi | 2 + 7 files changed, 271 insertions(+), 1 deletion(-) create mode 100644 stubs/PyAutoGUI/METADATA.toml create mode 100644 stubs/PyAutoGUI/pyautogui/__init__.pyi create mode 100644 stubs/PyAutoGUI/pyautogui/_pyautogui_java.pyi create mode 100644 stubs/PyAutoGUI/pyautogui/_pyautogui_osx.pyi create mode 100644 stubs/PyAutoGUI/pyautogui/_pyautogui_win.pyi create mode 100644 stubs/PyAutoGUI/pyautogui/_pyautogui_x11.pyi diff --git a/pyrightconfig.stricter.json b/pyrightconfig.stricter.json index 2a335d75f698..c38a943faf8b 100644 --- a/pyrightconfig.stricter.json +++ b/pyrightconfig.stricter.json @@ -90,7 +90,8 @@ "stubs/tzlocal/tzlocal/utils.pyi", "stubs/ttkthemes", "stubs/urllib3", - "stubs/vobject" + "stubs/vobject", + "stubs/PyAutoGUI" ], "typeCheckingMode": "basic", "strictListInference": true, diff --git a/stubs/PyAutoGUI/METADATA.toml b/stubs/PyAutoGUI/METADATA.toml new file mode 100644 index 000000000000..1548770aaef9 --- /dev/null +++ b/stubs/PyAutoGUI/METADATA.toml @@ -0,0 +1,4 @@ +version = "0.9.*" + +[tool.stubtest] +ignore_missing_stub = false diff --git a/stubs/PyAutoGUI/pyautogui/__init__.pyi b/stubs/PyAutoGUI/pyautogui/__init__.pyi new file mode 100644 index 000000000000..1c5d1ddba4e4 --- /dev/null +++ b/stubs/PyAutoGUI/pyautogui/__init__.pyi @@ -0,0 +1,233 @@ +import collections.abc +from _typeshed import Incomplete +from collections.abc import Callable, Generator +from datetime import datetime +from typing import NamedTuple, TypeVar, overload +from typing_extensions import ParamSpec + +# from pyscreeze import Box + +class PyAutoGUIException(Exception): ... +class FailSafeException(PyAutoGUIException): ... +class ImageNotFoundException(PyAutoGUIException): ... + +collectionsSequence = collections.abc.Sequence + +_P = ParamSpec("_P") +_R = TypeVar("_R") + +# TODO: Complete types with pyscreeze once we can import non-types dependencies +# See: https://github.com/python/typeshed/issues/5768 + +class _Box(NamedTuple): + left: int + top: int + width: int + height: int + +def raisePyAutoGUIImageNotFoundException(wrappedFunction: Callable[_P, _R]) -> Callable[_P, _R]: ... +def locate(*args: Incomplete, **kwargs: Incomplete) -> _Box | None: ... +def locateAll(*args: Incomplete, **kwargs: Incomplete) -> Generator[_Box, None, None]: ... +def locateAllOnScreen(*args: Incomplete, **kwargs: Incomplete) -> Generator[_Box, None, None]: ... +def locateCenterOnScreen(*args: Incomplete, **kwargs: Incomplete) -> Point | None: ... +def locateOnScreen(*args: Incomplete, **kwargs: Incomplete) -> _Box | None: ... +def locateOnWindow(*args: Incomplete, **kwargs: Incomplete) -> _Box | None: ... +def mouseInfo() -> None: ... +def useImageNotFoundException(value: bool | None = ...) -> None: ... + +KEY_NAMES: list[str] +KEYBOARD_KEYS: list[str] +LEFT: str +MIDDLE: str +RIGHT: str +PRIMARY: str +SECONDARY: str +QWERTY: str +QWERTZ: str + +def isShiftCharacter(character: str) -> bool: ... + +MINIMUM_DURATION: float +MINIMUM_SLEEP: float +PAUSE: float +DARWIN_CATCH_UP_TIME: float +FAILSAFE: bool +FAILSAFE_POINTS: list[tuple[int, int]] +LOG_SCREENSHOTS: bool +LOG_SCREENSHOTS_LIMIT: int +G_LOG_SCREENSHOTS_FILENAMES: list[str] + +class Point(NamedTuple): + x: float + y: float + +class Size(NamedTuple): + width: int + height: int + +def getPointOnLine(x1: float, y1: float, x2: float, y2: float, n: float) -> tuple[float, float]: ... +def linear(n: float) -> float: ... +def position(x: int | None = ..., y: int | None = ...) -> Point: ... +def size() -> Size: ... +@overload +def onScreen(xy: tuple[float, float]) -> bool: ... +@overload +def onScreen(x: float, y: float) -> bool: ... +def mouseDown( + x: float | collectionsSequence[int] | None = ..., + y: float | collectionsSequence[int] | None = ..., + button: str = ..., + duration: float = ..., + tween: Callable[[float], float] = ..., + logScreenshot: bool | None = ..., + _pause: bool = ..., +) -> None: ... +def mouseUp( + x: float | collectionsSequence[int] | None = ..., + y: float | collectionsSequence[int] | None = ..., + button: str = ..., + duration: float = ..., + tween: Callable[[float], float] = ..., + logScreenshot: bool | None = ..., + _pause: bool = ..., +) -> None: ... +def click( + x: float | collectionsSequence[int] | None = ..., + y: float | collectionsSequence[int] | None = ..., + clicks: int = ..., + interval: float = ..., + button: str = ..., + duration: float = ..., + tween: Callable[[float], float] = ..., + logScreenshot: bool | None = ..., + _pause: bool = ..., +) -> None: ... +def leftClick( + x: float | collectionsSequence[int] | None = ..., + y: float | collectionsSequence[int] | None = ..., + interval: float = ..., + duration: float = ..., + tween: Callable[[float], float] = ..., + logScreenshot: bool | None = ..., + _pause: bool = ..., +) -> None: ... +def rightClick( + x: float | collectionsSequence[int] | None = ..., + y: float | collectionsSequence[int] | None = ..., + interval: float = ..., + duration: float = ..., + tween: Callable[[float], float] = ..., + logScreenshot: bool | None = ..., + _pause: bool = ..., +) -> None: ... +def middleClick( + x: float | collectionsSequence[int] | None = ..., + y: float | collectionsSequence[int] | None = ..., + interval: float = ..., + duration: float = ..., + tween: Callable[[float], float] = ..., + logScreenshot: bool | None = ..., + _pause: bool = ..., +) -> None: ... +def doubleClick( + x: float | collectionsSequence[int] | None = ..., + y: float | collectionsSequence[int] | None = ..., + interval: float = ..., + button: str = ..., + duration: float = ..., + tween: Callable[[float], float] = ..., + logScreenshot: bool | None = ..., + _pause: bool = ..., +) -> None: ... +def tripleClick( + x: float | collectionsSequence[int] | None = ..., + y: float | collectionsSequence[int] | None = ..., + interval: float = ..., + button: str = ..., + duration: float = ..., + tween: Callable[[float], float] = ..., + logScreenshot: bool | None = ..., + _pause: bool = ..., +) -> None: ... +def scroll( + clicks: float, + x: float | collectionsSequence[int] | None = ..., + y: float | collectionsSequence[int] | None = ..., + logScreenshot: bool | None = ..., + _pause: bool = ..., +) -> None: ... +def hscroll( + clicks: float, + x: float | collectionsSequence[int] | None = ..., + y: float | collectionsSequence[int] | None = ..., + logScreenshot: bool | None = ..., + _pause: bool = ..., +) -> None: ... +def vscroll( + clicks: float, + x: float | collectionsSequence[int] | None = ..., + y: float | collectionsSequence[int] | None = ..., + logScreenshot: bool | None = ..., + _pause: bool = ..., +) -> None: ... +def moveTo( + x: float | collectionsSequence[int] | None = ..., + y: float | collectionsSequence[int] | None = ..., + duration: float = ..., + tween: Callable[[float], float] = ..., + logScreenshot: bool = ..., + _pause: bool = ..., +) -> None: ... +def moveRel( + xOffset: float | collectionsSequence[int] | None = ..., + yOffset: float | collectionsSequence[int] | None = ..., + duration: float = ..., + tween: Callable[[float], float] = ..., + logScreenshot: bool = ..., + _pause: bool = ..., +) -> None: ... + +move = moveRel + +def dragTo( + x: float | collectionsSequence[int] | None = ..., + y: float | collectionsSequence[int] | None = ..., + duration: float = ..., + tween: Callable[[float], float] = ..., + button: str = ..., + logScreenshot: bool | None = ..., + _pause: bool = ..., + mouseDownUp: bool = ..., +) -> None: ... +def dragRel( + xOffset: float | collectionsSequence[int] = ..., + yOffset: float | collectionsSequence[int] = ..., + duration: float = ..., + tween: Callable[[float], float] = ..., + button: str = ..., + logScreenshot: bool | None = ..., + _pause: bool = ..., + mouseDownUp: bool = ..., +) -> None: ... + +drag = dragRel + +def isValidKey(key: str) -> bool: ... +def keyDown(key: str, logScreenshot: bool | None = ..., _pause: bool = ...) -> None: ... +def keyUp(key: str, logScreenshot: bool | None = ..., _pause: bool = ...) -> None: ... +def press( + keys: str | list[str], presses: int = ..., interval: float = ..., logScreenshot: bool | None = ..., _pause: bool = ... +) -> None: ... +def hold(keys: str | list[str], logScreenshot: bool | None = ..., _pause: bool = ...) -> Generator[None, None, None]: ... +def typewrite(message: str | list[str], interval: float = ..., logScreenshot: bool | None = ..., _pause: bool = ...) -> None: ... + +write = typewrite + +def hotkey(*args: str, **kwargs: float | bool | None) -> None: ... +def failSafeCheck() -> None: ... +def displayMousePosition(xOffset: float = ..., yOffset: float = ...) -> None: ... +def sleep(seconds: int) -> None: ... +def countdown(seconds: int) -> None: ... +def run(commandStr: str, _ssCount: list[int] | None = ...) -> None: ... +def printInfo(dontPrint: bool = ...) -> str: ... +def getInfo() -> tuple[str, str, str, str, Size, datetime]: ... diff --git a/stubs/PyAutoGUI/pyautogui/_pyautogui_java.pyi b/stubs/PyAutoGUI/pyautogui/_pyautogui_java.pyi new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/stubs/PyAutoGUI/pyautogui/_pyautogui_osx.pyi b/stubs/PyAutoGUI/pyautogui/_pyautogui_osx.pyi new file mode 100644 index 000000000000..569791ac64ac --- /dev/null +++ b/stubs/PyAutoGUI/pyautogui/_pyautogui_osx.pyi @@ -0,0 +1,2 @@ +keyboardMapping: dict[str, int] +special_key_translate_table: dict[str, int] diff --git a/stubs/PyAutoGUI/pyautogui/_pyautogui_win.pyi b/stubs/PyAutoGUI/pyautogui/_pyautogui_win.pyi new file mode 100644 index 000000000000..4b9f5a4272d9 --- /dev/null +++ b/stubs/PyAutoGUI/pyautogui/_pyautogui_win.pyi @@ -0,0 +1,28 @@ +import ctypes + +MOUSEEVENTF_MOVE: int +MOUSEEVENTF_LEFTDOWN: int +MOUSEEVENTF_LEFTUP: int +MOUSEEVENTF_LEFTCLICK: int +MOUSEEVENTF_RIGHTDOWN: int +MOUSEEVENTF_RIGHTUP: int +MOUSEEVENTF_RIGHTCLICK: int +MOUSEEVENTF_MIDDLEDOWN: int +MOUSEEVENTF_MIDDLEUP: int +MOUSEEVENTF_MIDDLECLICK: int +MOUSEEVENTF_ABSOLUTE: int +MOUSEEVENTF_WHEEL: int +MOUSEEVENTF_HWHEEL: int +KEYEVENTF_KEYDOWN: int +KEYEVENTF_KEYUP: int +INPUT_MOUSE: int +INPUT_KEYBOARD: int + +class MOUSEINPUT(ctypes.Structure): ... +class KEYBDINPUT(ctypes.Structure): ... +class HARDWAREINPUT(ctypes.Structure): ... + +class INPUT(ctypes.Structure): + class _I(ctypes.Union): ... + +keyboardMapping: dict[str, int] diff --git a/stubs/PyAutoGUI/pyautogui/_pyautogui_x11.pyi b/stubs/PyAutoGUI/pyautogui/_pyautogui_x11.pyi new file mode 100644 index 000000000000..24d90ecc866f --- /dev/null +++ b/stubs/PyAutoGUI/pyautogui/_pyautogui_x11.pyi @@ -0,0 +1,2 @@ +BUTTON_NAME_MAPPING: dict[str | int, int] +keyboardMapping: dict[str, int] From 54b67a2e0bf38de13775a3938846f92e1bb63de3 Mon Sep 17 00:00:00 2001 From: Avasam Date: Wed, 31 Aug 2022 10:21:36 -0400 Subject: [PATCH 02/13] Added stubtest_allowlist.txt --- stubs/PyAutoGUI/@tests/stubtest_allowlist.txt | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 stubs/PyAutoGUI/@tests/stubtest_allowlist.txt diff --git a/stubs/PyAutoGUI/@tests/stubtest_allowlist.txt b/stubs/PyAutoGUI/@tests/stubtest_allowlist.txt new file mode 100644 index 000000000000..8f0aa044017d --- /dev/null +++ b/stubs/PyAutoGUI/@tests/stubtest_allowlist.txt @@ -0,0 +1,7 @@ +# pyautogui requires a display, resulting in the following error on the CI: +# failed to import, KeyError: 'DISPLAY' +pyautogui +pyautogui._pyautogui_java +pyautogui._pyautogui_osx +pyautogui._pyautogui_win +pyautogui._pyautogui_x11 From 8a0e10e3c6ceffced07afd60a69064aa6dd8c534 Mon Sep 17 00:00:00 2001 From: Avasam Date: Wed, 31 Aug 2022 19:19:50 -0400 Subject: [PATCH 03/13] Completed ctypes.Structure classes --- pyrightconfig.stricter.json | 4 +- stubs/PyAutoGUI/@tests/stubtest_allowlist.txt | 4 +- stubs/PyAutoGUI/pyautogui/__init__.pyi | 85 +++++++++---------- stubs/PyAutoGUI/pyautogui/_pyautogui_win.pyi | 45 +++++++++- 4 files changed, 87 insertions(+), 51 deletions(-) diff --git a/pyrightconfig.stricter.json b/pyrightconfig.stricter.json index c38a943faf8b..f257208ecd13 100644 --- a/pyrightconfig.stricter.json +++ b/pyrightconfig.stricter.json @@ -69,6 +69,7 @@ "stubs/pep8-naming", "stubs/psutil", "stubs/psycopg2", + "stubs/PyAutoGUI", "stubs/pyflakes", "stubs/Pygments", "stubs/PyMySQL", @@ -90,8 +91,7 @@ "stubs/tzlocal/tzlocal/utils.pyi", "stubs/ttkthemes", "stubs/urllib3", - "stubs/vobject", - "stubs/PyAutoGUI" + "stubs/vobject" ], "typeCheckingMode": "basic", "strictListInference": true, diff --git a/stubs/PyAutoGUI/@tests/stubtest_allowlist.txt b/stubs/PyAutoGUI/@tests/stubtest_allowlist.txt index 8f0aa044017d..fd10f0e6b1fe 100644 --- a/stubs/PyAutoGUI/@tests/stubtest_allowlist.txt +++ b/stubs/PyAutoGUI/@tests/stubtest_allowlist.txt @@ -2,6 +2,8 @@ # failed to import, KeyError: 'DISPLAY' pyautogui pyautogui._pyautogui_java -pyautogui._pyautogui_osx +pyautogui._pyautogui_osx # AssertionError: You must first install pyobjc-core and pyobjc pyautogui._pyautogui_win pyautogui._pyautogui_x11 +# overload +pyautogui.onScreen diff --git a/stubs/PyAutoGUI/pyautogui/__init__.pyi b/stubs/PyAutoGUI/pyautogui/__init__.pyi index 1c5d1ddba4e4..ad9bbd2506de 100644 --- a/stubs/PyAutoGUI/pyautogui/__init__.pyi +++ b/stubs/PyAutoGUI/pyautogui/__init__.pyi @@ -1,6 +1,4 @@ -import collections.abc -from _typeshed import Incomplete -from collections.abc import Callable, Generator +from collections.abc import Callable, Generator, Sequence from datetime import datetime from typing import NamedTuple, TypeVar, overload from typing_extensions import ParamSpec @@ -11,13 +9,12 @@ class PyAutoGUIException(Exception): ... class FailSafeException(PyAutoGUIException): ... class ImageNotFoundException(PyAutoGUIException): ... -collectionsSequence = collections.abc.Sequence - _P = ParamSpec("_P") _R = TypeVar("_R") -# TODO: Complete types with pyscreeze once we can import non-types dependencies -# See: https://github.com/python/typeshed/issues/5768 +# TODO: Complete types with pyscreeze once we can import it as a type dependency +# Actually `pyscreeze.Box`, but typeshed doesn't currently have stubs for pyscreeze +# (and the library doesn't have type annotations either) class _Box(NamedTuple): left: int @@ -26,12 +23,12 @@ class _Box(NamedTuple): height: int def raisePyAutoGUIImageNotFoundException(wrappedFunction: Callable[_P, _R]) -> Callable[_P, _R]: ... -def locate(*args: Incomplete, **kwargs: Incomplete) -> _Box | None: ... -def locateAll(*args: Incomplete, **kwargs: Incomplete) -> Generator[_Box, None, None]: ... -def locateAllOnScreen(*args: Incomplete, **kwargs: Incomplete) -> Generator[_Box, None, None]: ... -def locateCenterOnScreen(*args: Incomplete, **kwargs: Incomplete) -> Point | None: ... -def locateOnScreen(*args: Incomplete, **kwargs: Incomplete) -> _Box | None: ... -def locateOnWindow(*args: Incomplete, **kwargs: Incomplete) -> _Box | None: ... +def locate(*args, **kwargs) -> _Box | None: ... +def locateAll(*args, **kwargs) -> Generator[_Box, None, None]: ... +def locateAllOnScreen(*args, **kwargs) -> Generator[_Box, None, None]: ... +def locateCenterOnScreen(*args, **kwargs) -> Point | None: ... +def locateOnScreen(*args, **kwargs) -> _Box | None: ... +def locateOnWindow(*args, **kwargs) -> _Box | None: ... def mouseInfo() -> None: ... def useImageNotFoundException(value: bool | None = ...) -> None: ... @@ -70,12 +67,12 @@ def linear(n: float) -> float: ... def position(x: int | None = ..., y: int | None = ...) -> Point: ... def size() -> Size: ... @overload -def onScreen(xy: tuple[float, float]) -> bool: ... +def onScreen(point: tuple[float, float], _: None = ...) -> bool: ... @overload def onScreen(x: float, y: float) -> bool: ... def mouseDown( - x: float | collectionsSequence[int] | None = ..., - y: float | collectionsSequence[int] | None = ..., + x: float | Sequence[int] | None = ..., + y: float | Sequence[int] | None = ..., button: str = ..., duration: float = ..., tween: Callable[[float], float] = ..., @@ -83,8 +80,8 @@ def mouseDown( _pause: bool = ..., ) -> None: ... def mouseUp( - x: float | collectionsSequence[int] | None = ..., - y: float | collectionsSequence[int] | None = ..., + x: float | Sequence[int] | None = ..., + y: float | Sequence[int] | None = ..., button: str = ..., duration: float = ..., tween: Callable[[float], float] = ..., @@ -92,8 +89,8 @@ def mouseUp( _pause: bool = ..., ) -> None: ... def click( - x: float | collectionsSequence[int] | None = ..., - y: float | collectionsSequence[int] | None = ..., + x: float | Sequence[int] | None = ..., + y: float | Sequence[int] | None = ..., clicks: int = ..., interval: float = ..., button: str = ..., @@ -103,8 +100,8 @@ def click( _pause: bool = ..., ) -> None: ... def leftClick( - x: float | collectionsSequence[int] | None = ..., - y: float | collectionsSequence[int] | None = ..., + x: float | Sequence[int] | None = ..., + y: float | Sequence[int] | None = ..., interval: float = ..., duration: float = ..., tween: Callable[[float], float] = ..., @@ -112,8 +109,8 @@ def leftClick( _pause: bool = ..., ) -> None: ... def rightClick( - x: float | collectionsSequence[int] | None = ..., - y: float | collectionsSequence[int] | None = ..., + x: float | Sequence[int] | None = ..., + y: float | Sequence[int] | None = ..., interval: float = ..., duration: float = ..., tween: Callable[[float], float] = ..., @@ -121,8 +118,8 @@ def rightClick( _pause: bool = ..., ) -> None: ... def middleClick( - x: float | collectionsSequence[int] | None = ..., - y: float | collectionsSequence[int] | None = ..., + x: float | Sequence[int] | None = ..., + y: float | Sequence[int] | None = ..., interval: float = ..., duration: float = ..., tween: Callable[[float], float] = ..., @@ -130,8 +127,8 @@ def middleClick( _pause: bool = ..., ) -> None: ... def doubleClick( - x: float | collectionsSequence[int] | None = ..., - y: float | collectionsSequence[int] | None = ..., + x: float | Sequence[int] | None = ..., + y: float | Sequence[int] | None = ..., interval: float = ..., button: str = ..., duration: float = ..., @@ -140,8 +137,8 @@ def doubleClick( _pause: bool = ..., ) -> None: ... def tripleClick( - x: float | collectionsSequence[int] | None = ..., - y: float | collectionsSequence[int] | None = ..., + x: float | Sequence[int] | None = ..., + y: float | Sequence[int] | None = ..., interval: float = ..., button: str = ..., duration: float = ..., @@ -151,36 +148,36 @@ def tripleClick( ) -> None: ... def scroll( clicks: float, - x: float | collectionsSequence[int] | None = ..., - y: float | collectionsSequence[int] | None = ..., + x: float | Sequence[int] | None = ..., + y: float | Sequence[int] | None = ..., logScreenshot: bool | None = ..., _pause: bool = ..., ) -> None: ... def hscroll( clicks: float, - x: float | collectionsSequence[int] | None = ..., - y: float | collectionsSequence[int] | None = ..., + x: float | Sequence[int] | None = ..., + y: float | Sequence[int] | None = ..., logScreenshot: bool | None = ..., _pause: bool = ..., ) -> None: ... def vscroll( clicks: float, - x: float | collectionsSequence[int] | None = ..., - y: float | collectionsSequence[int] | None = ..., + x: float | Sequence[int] | None = ..., + y: float | Sequence[int] | None = ..., logScreenshot: bool | None = ..., _pause: bool = ..., ) -> None: ... def moveTo( - x: float | collectionsSequence[int] | None = ..., - y: float | collectionsSequence[int] | None = ..., + x: float | Sequence[int] | None = ..., + y: float | Sequence[int] | None = ..., duration: float = ..., tween: Callable[[float], float] = ..., logScreenshot: bool = ..., _pause: bool = ..., ) -> None: ... def moveRel( - xOffset: float | collectionsSequence[int] | None = ..., - yOffset: float | collectionsSequence[int] | None = ..., + xOffset: float | Sequence[int] | None = ..., + yOffset: float | Sequence[int] | None = ..., duration: float = ..., tween: Callable[[float], float] = ..., logScreenshot: bool = ..., @@ -190,8 +187,8 @@ def moveRel( move = moveRel def dragTo( - x: float | collectionsSequence[int] | None = ..., - y: float | collectionsSequence[int] | None = ..., + x: float | Sequence[int] | None = ..., + y: float | Sequence[int] | None = ..., duration: float = ..., tween: Callable[[float], float] = ..., button: str = ..., @@ -200,8 +197,8 @@ def dragTo( mouseDownUp: bool = ..., ) -> None: ... def dragRel( - xOffset: float | collectionsSequence[int] = ..., - yOffset: float | collectionsSequence[int] = ..., + xOffset: float | Sequence[int] = ..., + yOffset: float | Sequence[int] = ..., duration: float = ..., tween: Callable[[float], float] = ..., button: str = ..., diff --git a/stubs/PyAutoGUI/pyautogui/_pyautogui_win.pyi b/stubs/PyAutoGUI/pyautogui/_pyautogui_win.pyi index 4b9f5a4272d9..70b947dd97a5 100644 --- a/stubs/PyAutoGUI/pyautogui/_pyautogui_win.pyi +++ b/stubs/PyAutoGUI/pyautogui/_pyautogui_win.pyi @@ -1,4 +1,11 @@ +from _typeshed import Incomplete import ctypes +import ctypes.wintypes +from typing_extensions import TypeAlias +from pyautogui import LEFT as LEFT, MIDDLE as MIDDLE, RIGHT as RIGHT + +_Pointer: TypeAlias = Incomplete + MOUSEEVENTF_MOVE: int MOUSEEVENTF_LEFTDOWN: int @@ -18,11 +25,41 @@ KEYEVENTF_KEYUP: int INPUT_MOUSE: int INPUT_KEYBOARD: int -class MOUSEINPUT(ctypes.Structure): ... -class KEYBDINPUT(ctypes.Structure): ... -class HARDWAREINPUT(ctypes.Structure): ... + +class MOUSEINPUT(ctypes.Structure): + dx: ctypes.wintypes.LONG + dy: ctypes.wintypes.LONG + mouseData: ctypes.wintypes.DWORD + dwFlags: ctypes.wintypes.DWORD + time: ctypes.wintypes.DWORD + dwExtraInfo: _Pointer + + +class KEYBDINPUT(ctypes.Structure): + wVk: ctypes.wintypes.WORD + wScan: ctypes.wintypes.WORD + dwFlags: ctypes.wintypes.DWORD + time: ctypes.wintypes.DWORD + dwExtraInfo: _Pointer + + +class HARDWAREINPUT(ctypes.Structure): + uMsg: ctypes.wintypes.DWORD + wParamL: ctypes.wintypes.WORD + wParamH: ctypes.wintypes.DWORD + class INPUT(ctypes.Structure): - class _I(ctypes.Union): ... + class _I(ctypes.Union): + mi: MOUSEINPUT + ki: KEYBDINPUT + hi: HARDWAREINPUT + + mi: MOUSEINPUT + ki: KEYBDINPUT + hi: HARDWAREINPUT + type: ctypes.wintypes.DWORD + i: _I + keyboardMapping: dict[str, int] From 498e83739ad3fef03ef76cd22d2ab6006fe54af3 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 31 Aug 2022 23:21:20 +0000 Subject: [PATCH 04/13] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stubs/PyAutoGUI/pyautogui/_pyautogui_win.pyi | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/stubs/PyAutoGUI/pyautogui/_pyautogui_win.pyi b/stubs/PyAutoGUI/pyautogui/_pyautogui_win.pyi index 70b947dd97a5..259bbaba7667 100644 --- a/stubs/PyAutoGUI/pyautogui/_pyautogui_win.pyi +++ b/stubs/PyAutoGUI/pyautogui/_pyautogui_win.pyi @@ -1,12 +1,12 @@ -from _typeshed import Incomplete import ctypes import ctypes.wintypes +from _typeshed import Incomplete from typing_extensions import TypeAlias + from pyautogui import LEFT as LEFT, MIDDLE as MIDDLE, RIGHT as RIGHT _Pointer: TypeAlias = Incomplete - MOUSEEVENTF_MOVE: int MOUSEEVENTF_LEFTDOWN: int MOUSEEVENTF_LEFTUP: int @@ -25,7 +25,6 @@ KEYEVENTF_KEYUP: int INPUT_MOUSE: int INPUT_KEYBOARD: int - class MOUSEINPUT(ctypes.Structure): dx: ctypes.wintypes.LONG dy: ctypes.wintypes.LONG @@ -34,7 +33,6 @@ class MOUSEINPUT(ctypes.Structure): time: ctypes.wintypes.DWORD dwExtraInfo: _Pointer - class KEYBDINPUT(ctypes.Structure): wVk: ctypes.wintypes.WORD wScan: ctypes.wintypes.WORD @@ -42,24 +40,20 @@ class KEYBDINPUT(ctypes.Structure): time: ctypes.wintypes.DWORD dwExtraInfo: _Pointer - class HARDWAREINPUT(ctypes.Structure): uMsg: ctypes.wintypes.DWORD wParamL: ctypes.wintypes.WORD wParamH: ctypes.wintypes.DWORD - class INPUT(ctypes.Structure): class _I(ctypes.Union): mi: MOUSEINPUT ki: KEYBDINPUT hi: HARDWAREINPUT - mi: MOUSEINPUT ki: KEYBDINPUT hi: HARDWAREINPUT type: ctypes.wintypes.DWORD i: _I - keyboardMapping: dict[str, int] From df1f303dde219f2fa8a8e357fda0713ba2f5af8c Mon Sep 17 00:00:00 2001 From: Avasam Date: Wed, 31 Aug 2022 19:27:30 -0400 Subject: [PATCH 05/13] Unused allowlist --- stubs/PyAutoGUI/@tests/stubtest_allowlist.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/stubs/PyAutoGUI/@tests/stubtest_allowlist.txt b/stubs/PyAutoGUI/@tests/stubtest_allowlist.txt index fd10f0e6b1fe..4500a9c7afe6 100644 --- a/stubs/PyAutoGUI/@tests/stubtest_allowlist.txt +++ b/stubs/PyAutoGUI/@tests/stubtest_allowlist.txt @@ -5,5 +5,3 @@ pyautogui._pyautogui_java pyautogui._pyautogui_osx # AssertionError: You must first install pyobjc-core and pyobjc pyautogui._pyautogui_win pyautogui._pyautogui_x11 -# overload -pyautogui.onScreen From 63fd405a2e5beb728dd15ea0a2b2271f3a098fbc Mon Sep 17 00:00:00 2001 From: Avasam Date: Wed, 31 Aug 2022 19:55:26 -0400 Subject: [PATCH 06/13] ctypes.wintypes.PULONG --- stubs/PyAutoGUI/pyautogui/_pyautogui_win.pyi | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/stubs/PyAutoGUI/pyautogui/_pyautogui_win.pyi b/stubs/PyAutoGUI/pyautogui/_pyautogui_win.pyi index 259bbaba7667..42c7e432ca5d 100644 --- a/stubs/PyAutoGUI/pyautogui/_pyautogui_win.pyi +++ b/stubs/PyAutoGUI/pyautogui/_pyautogui_win.pyi @@ -1,12 +1,8 @@ import ctypes import ctypes.wintypes -from _typeshed import Incomplete -from typing_extensions import TypeAlias from pyautogui import LEFT as LEFT, MIDDLE as MIDDLE, RIGHT as RIGHT -_Pointer: TypeAlias = Incomplete - MOUSEEVENTF_MOVE: int MOUSEEVENTF_LEFTDOWN: int MOUSEEVENTF_LEFTUP: int @@ -31,14 +27,14 @@ class MOUSEINPUT(ctypes.Structure): mouseData: ctypes.wintypes.DWORD dwFlags: ctypes.wintypes.DWORD time: ctypes.wintypes.DWORD - dwExtraInfo: _Pointer + dwExtraInfo: ctypes.wintypes.PULONG class KEYBDINPUT(ctypes.Structure): wVk: ctypes.wintypes.WORD wScan: ctypes.wintypes.WORD dwFlags: ctypes.wintypes.DWORD time: ctypes.wintypes.DWORD - dwExtraInfo: _Pointer + dwExtraInfo: ctypes.wintypes.PULONG class HARDWAREINPUT(ctypes.Structure): uMsg: ctypes.wintypes.DWORD From ebf407151c8d78c0191415df8249da29bb9a3ded Mon Sep 17 00:00:00 2001 From: Avasam Date: Fri, 2 Sep 2022 12:58:04 -0400 Subject: [PATCH 07/13] PR comments --- stubs/PyAutoGUI/pyautogui/__init__.pyi | 84 ++++++++++++++------------ 1 file changed, 46 insertions(+), 38 deletions(-) diff --git a/stubs/PyAutoGUI/pyautogui/__init__.pyi b/stubs/PyAutoGUI/pyautogui/__init__.pyi index ad9bbd2506de..4c20ea9350cd 100644 --- a/stubs/PyAutoGUI/pyautogui/__init__.pyi +++ b/stubs/PyAutoGUI/pyautogui/__init__.pyi @@ -1,6 +1,6 @@ from collections.abc import Callable, Generator, Sequence from datetime import datetime -from typing import NamedTuple, TypeVar, overload +from typing import Iterable, NamedTuple, TypeVar, overload from typing_extensions import ParamSpec # from pyscreeze import Box @@ -23,6 +23,7 @@ class _Box(NamedTuple): height: int def raisePyAutoGUIImageNotFoundException(wrappedFunction: Callable[_P, _R]) -> Callable[_P, _R]: ... +# These functions reuse pyscreeze functions directly. See above TODO. def locate(*args, **kwargs) -> _Box | None: ... def locateAll(*args, **kwargs) -> Generator[_Box, None, None]: ... def locateAllOnScreen(*args, **kwargs) -> Generator[_Box, None, None]: ... @@ -67,12 +68,13 @@ def linear(n: float) -> float: ... def position(x: int | None = ..., y: int | None = ...) -> Point: ... def size() -> Size: ... @overload -def onScreen(point: tuple[float, float], _: None = ...) -> bool: ... +def onScreen(x: tuple[float, float], y: None = ...) -> bool: ... @overload def onScreen(x: float, y: float) -> bool: ... def mouseDown( - x: float | Sequence[int] | None = ..., - y: float | Sequence[int] | None = ..., + x: float | Sequence[float] | str | None = ..., + y: float | None = ..., + # Docstring says `button` can also be `int`, but `.lower()` is called unconditionally in `_normalizeButton()` button: str = ..., duration: float = ..., tween: Callable[[float], float] = ..., @@ -80,8 +82,9 @@ def mouseDown( _pause: bool = ..., ) -> None: ... def mouseUp( - x: float | Sequence[int] | None = ..., - y: float | Sequence[int] | None = ..., + x: float | Sequence[float] | str | None = ..., + y: float | None = ..., + # Docstring says `button` can also be `int`, but `.lower()` is called unconditionally in `_normalizeButton()` button: str = ..., duration: float = ..., tween: Callable[[float], float] = ..., @@ -89,10 +92,11 @@ def mouseUp( _pause: bool = ..., ) -> None: ... def click( - x: float | Sequence[int] | None = ..., - y: float | Sequence[int] | None = ..., + x: float | Sequence[float] | str | None = ..., + y: float | None = ..., clicks: int = ..., interval: float = ..., + # Docstring says `button` can also be `int`, but `.lower()` is called unconditionally in `_normalizeButton()` button: str = ..., duration: float = ..., tween: Callable[[float], float] = ..., @@ -100,8 +104,8 @@ def click( _pause: bool = ..., ) -> None: ... def leftClick( - x: float | Sequence[int] | None = ..., - y: float | Sequence[int] | None = ..., + x: float | Sequence[float] | str | None = ..., + y: float | None = ..., interval: float = ..., duration: float = ..., tween: Callable[[float], float] = ..., @@ -109,8 +113,8 @@ def leftClick( _pause: bool = ..., ) -> None: ... def rightClick( - x: float | Sequence[int] | None = ..., - y: float | Sequence[int] | None = ..., + x: float | Sequence[float] | str | None = ..., + y: float | None = ..., interval: float = ..., duration: float = ..., tween: Callable[[float], float] = ..., @@ -118,8 +122,8 @@ def rightClick( _pause: bool = ..., ) -> None: ... def middleClick( - x: float | Sequence[int] | None = ..., - y: float | Sequence[int] | None = ..., + x: float | Sequence[float] | str | None = ..., + y: float | None = ..., interval: float = ..., duration: float = ..., tween: Callable[[float], float] = ..., @@ -127,9 +131,10 @@ def middleClick( _pause: bool = ..., ) -> None: ... def doubleClick( - x: float | Sequence[int] | None = ..., - y: float | Sequence[int] | None = ..., + x: float | Sequence[float] | str | None = ..., + y: float | None = ..., interval: float = ..., + # Docstring says `button` can also be `int`, but `.lower()` is called unconditionally in `_normalizeButton()` button: str = ..., duration: float = ..., tween: Callable[[float], float] = ..., @@ -137,9 +142,10 @@ def doubleClick( _pause: bool = ..., ) -> None: ... def tripleClick( - x: float | Sequence[int] | None = ..., - y: float | Sequence[int] | None = ..., + x: float | Sequence[float] | str | None = ..., + y: float | None = ..., interval: float = ..., + # Docstring says `button` can also be `int`, but `.lower()` is called unconditionally in `_normalizeButton()` button: str = ..., duration: float = ..., tween: Callable[[float], float] = ..., @@ -148,36 +154,36 @@ def tripleClick( ) -> None: ... def scroll( clicks: float, - x: float | Sequence[int] | None = ..., - y: float | Sequence[int] | None = ..., + x: float | Sequence[float] | str | None = ..., + y: float | None = ..., logScreenshot: bool | None = ..., _pause: bool = ..., ) -> None: ... def hscroll( clicks: float, - x: float | Sequence[int] | None = ..., - y: float | Sequence[int] | None = ..., + x: float | Sequence[float] | str | None = ..., + y: float | None = ..., logScreenshot: bool | None = ..., _pause: bool = ..., ) -> None: ... def vscroll( clicks: float, - x: float | Sequence[int] | None = ..., - y: float | Sequence[int] | None = ..., + x: float | Sequence[float] | str | None = ..., + y: float | None = ..., logScreenshot: bool | None = ..., _pause: bool = ..., ) -> None: ... def moveTo( - x: float | Sequence[int] | None = ..., - y: float | Sequence[int] | None = ..., + x: float | Sequence[float] | str | None = ..., + y: float | None = ..., duration: float = ..., tween: Callable[[float], float] = ..., logScreenshot: bool = ..., _pause: bool = ..., ) -> None: ... def moveRel( - xOffset: float | Sequence[int] | None = ..., - yOffset: float | Sequence[int] | None = ..., + xOffset: float | Sequence[float] | str | None = ..., + yOffset: float | None = ..., duration: float = ..., tween: Callable[[float], float] = ..., logScreenshot: bool = ..., @@ -187,20 +193,22 @@ def moveRel( move = moveRel def dragTo( - x: float | Sequence[int] | None = ..., - y: float | Sequence[int] | None = ..., + x: float | Sequence[float] | str | None = ..., + y: float | None = ..., duration: float = ..., tween: Callable[[float], float] = ..., + # Docstring says `button` can also be `int`, but `.lower()` is called unconditionally in `_normalizeButton()` button: str = ..., logScreenshot: bool | None = ..., _pause: bool = ..., mouseDownUp: bool = ..., ) -> None: ... def dragRel( - xOffset: float | Sequence[int] = ..., - yOffset: float | Sequence[int] = ..., + xOffset: float | Sequence[float] | str = ..., + yOffset: float = ..., duration: float = ..., tween: Callable[[float], float] = ..., + # Docstring says `button` can also be `int`, but `.lower()` is called unconditionally in `_normalizeButton()` button: str = ..., logScreenshot: bool | None = ..., _pause: bool = ..., @@ -213,18 +221,18 @@ def isValidKey(key: str) -> bool: ... def keyDown(key: str, logScreenshot: bool | None = ..., _pause: bool = ...) -> None: ... def keyUp(key: str, logScreenshot: bool | None = ..., _pause: bool = ...) -> None: ... def press( - keys: str | list[str], presses: int = ..., interval: float = ..., logScreenshot: bool | None = ..., _pause: bool = ... + keys: str | Iterable[str], presses: int = ..., interval: float = ..., logScreenshot: bool | None = ..., _pause: bool = ... ) -> None: ... -def hold(keys: str | list[str], logScreenshot: bool | None = ..., _pause: bool = ...) -> Generator[None, None, None]: ... -def typewrite(message: str | list[str], interval: float = ..., logScreenshot: bool | None = ..., _pause: bool = ...) -> None: ... +def hold(keys: str | Iterable[str], logScreenshot: bool | None = ..., _pause: bool = ...) -> Generator[None, None, None]: ... +def typewrite(message: str | Iterable[str], interval: float = ..., logScreenshot: bool | None = ..., _pause: bool = ...) -> None: ... write = typewrite -def hotkey(*args: str, **kwargs: float | bool | None) -> None: ... +def hotkey(*args: str, logScreenshot: bool | None = ..., interval: float = ...) -> None: ... def failSafeCheck() -> None: ... def displayMousePosition(xOffset: float = ..., yOffset: float = ...) -> None: ... -def sleep(seconds: int) -> None: ... +def sleep(seconds: float) -> None: ... def countdown(seconds: int) -> None: ... -def run(commandStr: str, _ssCount: list[int] | None = ...) -> None: ... +def run(commandStr: str, _ssCount: Iterable[int] | None = ...) -> None: ... def printInfo(dontPrint: bool = ...) -> str: ... def getInfo() -> tuple[str, str, str, str, Size, datetime]: ... From 033af67d432279f9b28650155426aa63ce54be27 Mon Sep 17 00:00:00 2001 From: Avasam Date: Fri, 2 Sep 2022 13:08:41 -0400 Subject: [PATCH 08/13] Remove private stubs --- stubs/PyAutoGUI/pyautogui/_pyautogui_java.pyi | 0 stubs/PyAutoGUI/pyautogui/_pyautogui_osx.pyi | 2 - stubs/PyAutoGUI/pyautogui/_pyautogui_win.pyi | 55 ------------------- stubs/PyAutoGUI/pyautogui/_pyautogui_x11.pyi | 2 - 4 files changed, 59 deletions(-) delete mode 100644 stubs/PyAutoGUI/pyautogui/_pyautogui_java.pyi delete mode 100644 stubs/PyAutoGUI/pyautogui/_pyautogui_osx.pyi delete mode 100644 stubs/PyAutoGUI/pyautogui/_pyautogui_win.pyi delete mode 100644 stubs/PyAutoGUI/pyautogui/_pyautogui_x11.pyi diff --git a/stubs/PyAutoGUI/pyautogui/_pyautogui_java.pyi b/stubs/PyAutoGUI/pyautogui/_pyautogui_java.pyi deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/stubs/PyAutoGUI/pyautogui/_pyautogui_osx.pyi b/stubs/PyAutoGUI/pyautogui/_pyautogui_osx.pyi deleted file mode 100644 index 569791ac64ac..000000000000 --- a/stubs/PyAutoGUI/pyautogui/_pyautogui_osx.pyi +++ /dev/null @@ -1,2 +0,0 @@ -keyboardMapping: dict[str, int] -special_key_translate_table: dict[str, int] diff --git a/stubs/PyAutoGUI/pyautogui/_pyautogui_win.pyi b/stubs/PyAutoGUI/pyautogui/_pyautogui_win.pyi deleted file mode 100644 index 42c7e432ca5d..000000000000 --- a/stubs/PyAutoGUI/pyautogui/_pyautogui_win.pyi +++ /dev/null @@ -1,55 +0,0 @@ -import ctypes -import ctypes.wintypes - -from pyautogui import LEFT as LEFT, MIDDLE as MIDDLE, RIGHT as RIGHT - -MOUSEEVENTF_MOVE: int -MOUSEEVENTF_LEFTDOWN: int -MOUSEEVENTF_LEFTUP: int -MOUSEEVENTF_LEFTCLICK: int -MOUSEEVENTF_RIGHTDOWN: int -MOUSEEVENTF_RIGHTUP: int -MOUSEEVENTF_RIGHTCLICK: int -MOUSEEVENTF_MIDDLEDOWN: int -MOUSEEVENTF_MIDDLEUP: int -MOUSEEVENTF_MIDDLECLICK: int -MOUSEEVENTF_ABSOLUTE: int -MOUSEEVENTF_WHEEL: int -MOUSEEVENTF_HWHEEL: int -KEYEVENTF_KEYDOWN: int -KEYEVENTF_KEYUP: int -INPUT_MOUSE: int -INPUT_KEYBOARD: int - -class MOUSEINPUT(ctypes.Structure): - dx: ctypes.wintypes.LONG - dy: ctypes.wintypes.LONG - mouseData: ctypes.wintypes.DWORD - dwFlags: ctypes.wintypes.DWORD - time: ctypes.wintypes.DWORD - dwExtraInfo: ctypes.wintypes.PULONG - -class KEYBDINPUT(ctypes.Structure): - wVk: ctypes.wintypes.WORD - wScan: ctypes.wintypes.WORD - dwFlags: ctypes.wintypes.DWORD - time: ctypes.wintypes.DWORD - dwExtraInfo: ctypes.wintypes.PULONG - -class HARDWAREINPUT(ctypes.Structure): - uMsg: ctypes.wintypes.DWORD - wParamL: ctypes.wintypes.WORD - wParamH: ctypes.wintypes.DWORD - -class INPUT(ctypes.Structure): - class _I(ctypes.Union): - mi: MOUSEINPUT - ki: KEYBDINPUT - hi: HARDWAREINPUT - mi: MOUSEINPUT - ki: KEYBDINPUT - hi: HARDWAREINPUT - type: ctypes.wintypes.DWORD - i: _I - -keyboardMapping: dict[str, int] diff --git a/stubs/PyAutoGUI/pyautogui/_pyautogui_x11.pyi b/stubs/PyAutoGUI/pyautogui/_pyautogui_x11.pyi deleted file mode 100644 index 24d90ecc866f..000000000000 --- a/stubs/PyAutoGUI/pyautogui/_pyautogui_x11.pyi +++ /dev/null @@ -1,2 +0,0 @@ -BUTTON_NAME_MAPPING: dict[str | int, int] -keyboardMapping: dict[str, int] From 677bb85146ac125361bb81ef28aa94dae99f3842 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 2 Sep 2022 17:09:10 +0000 Subject: [PATCH 09/13] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stubs/PyAutoGUI/pyautogui/__init__.pyi | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/stubs/PyAutoGUI/pyautogui/__init__.pyi b/stubs/PyAutoGUI/pyautogui/__init__.pyi index 4c20ea9350cd..311cbe2674fa 100644 --- a/stubs/PyAutoGUI/pyautogui/__init__.pyi +++ b/stubs/PyAutoGUI/pyautogui/__init__.pyi @@ -23,6 +23,7 @@ class _Box(NamedTuple): height: int def raisePyAutoGUIImageNotFoundException(wrappedFunction: Callable[_P, _R]) -> Callable[_P, _R]: ... + # These functions reuse pyscreeze functions directly. See above TODO. def locate(*args, **kwargs) -> _Box | None: ... def locateAll(*args, **kwargs) -> Generator[_Box, None, None]: ... @@ -224,7 +225,9 @@ def press( keys: str | Iterable[str], presses: int = ..., interval: float = ..., logScreenshot: bool | None = ..., _pause: bool = ... ) -> None: ... def hold(keys: str | Iterable[str], logScreenshot: bool | None = ..., _pause: bool = ...) -> Generator[None, None, None]: ... -def typewrite(message: str | Iterable[str], interval: float = ..., logScreenshot: bool | None = ..., _pause: bool = ...) -> None: ... +def typewrite( + message: str | Iterable[str], interval: float = ..., logScreenshot: bool | None = ..., _pause: bool = ... +) -> None: ... write = typewrite From 354da3ab81153dfca0f569a5c7ffffbba60750c9 Mon Sep 17 00:00:00 2001 From: Avasam Date: Fri, 2 Sep 2022 13:26:13 -0400 Subject: [PATCH 10/13] typewrite and run check for length --- stubs/PyAutoGUI/pyautogui/__init__.pyi | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/stubs/PyAutoGUI/pyautogui/__init__.pyi b/stubs/PyAutoGUI/pyautogui/__init__.pyi index 4c20ea9350cd..55d01f6ab509 100644 --- a/stubs/PyAutoGUI/pyautogui/__init__.pyi +++ b/stubs/PyAutoGUI/pyautogui/__init__.pyi @@ -1,6 +1,6 @@ -from collections.abc import Callable, Generator, Sequence +from collections.abc import Callable, Generator, Iterable, Sequence from datetime import datetime -from typing import Iterable, NamedTuple, TypeVar, overload +from typing import NamedTuple, TypeVar, overload from typing_extensions import ParamSpec # from pyscreeze import Box @@ -23,6 +23,7 @@ class _Box(NamedTuple): height: int def raisePyAutoGUIImageNotFoundException(wrappedFunction: Callable[_P, _R]) -> Callable[_P, _R]: ... + # These functions reuse pyscreeze functions directly. See above TODO. def locate(*args, **kwargs) -> _Box | None: ... def locateAll(*args, **kwargs) -> Generator[_Box, None, None]: ... @@ -224,7 +225,9 @@ def press( keys: str | Iterable[str], presses: int = ..., interval: float = ..., logScreenshot: bool | None = ..., _pause: bool = ... ) -> None: ... def hold(keys: str | Iterable[str], logScreenshot: bool | None = ..., _pause: bool = ...) -> Generator[None, None, None]: ... -def typewrite(message: str | Iterable[str], interval: float = ..., logScreenshot: bool | None = ..., _pause: bool = ...) -> None: ... +def typewrite( + message: str | Sequence[str], interval: float = ..., logScreenshot: bool | None = ..., _pause: bool = ... +) -> None: ... write = typewrite @@ -233,6 +236,6 @@ def failSafeCheck() -> None: ... def displayMousePosition(xOffset: float = ..., yOffset: float = ...) -> None: ... def sleep(seconds: float) -> None: ... def countdown(seconds: int) -> None: ... -def run(commandStr: str, _ssCount: Iterable[int] | None = ...) -> None: ... +def run(commandStr: str, _ssCount: Sequence[int] | None = ...) -> None: ... def printInfo(dontPrint: bool = ...) -> str: ... def getInfo() -> tuple[str, str, str, str, Size, datetime]: ... From 69c05a7cdb3bb6b354e5bf1d7a4708ebe0072c0f Mon Sep 17 00:00:00 2001 From: Avasam Date: Fri, 2 Sep 2022 16:22:26 -0400 Subject: [PATCH 11/13] unused allowlist --- stubs/PyAutoGUI/@tests/stubtest_allowlist.txt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/stubs/PyAutoGUI/@tests/stubtest_allowlist.txt b/stubs/PyAutoGUI/@tests/stubtest_allowlist.txt index 4500a9c7afe6..5aef37e7cd18 100644 --- a/stubs/PyAutoGUI/@tests/stubtest_allowlist.txt +++ b/stubs/PyAutoGUI/@tests/stubtest_allowlist.txt @@ -1,7 +1,3 @@ # pyautogui requires a display, resulting in the following error on the CI: # failed to import, KeyError: 'DISPLAY' pyautogui -pyautogui._pyautogui_java -pyautogui._pyautogui_osx # AssertionError: You must first install pyobjc-core and pyobjc -pyautogui._pyautogui_win -pyautogui._pyautogui_x11 From 94711a0579ce2670f9e66b3c4262ebc858f291ba Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Sat, 3 Sep 2022 12:35:45 +0100 Subject: [PATCH 12/13] Fix signature of `hold()` --- stubs/PyAutoGUI/pyautogui/__init__.pyi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stubs/PyAutoGUI/pyautogui/__init__.pyi b/stubs/PyAutoGUI/pyautogui/__init__.pyi index 55d01f6ab509..2408139a33df 100644 --- a/stubs/PyAutoGUI/pyautogui/__init__.pyi +++ b/stubs/PyAutoGUI/pyautogui/__init__.pyi @@ -1,3 +1,4 @@ +import contextlib from collections.abc import Callable, Generator, Iterable, Sequence from datetime import datetime from typing import NamedTuple, TypeVar, overload @@ -224,7 +225,7 @@ def keyUp(key: str, logScreenshot: bool | None = ..., _pause: bool = ...) -> Non def press( keys: str | Iterable[str], presses: int = ..., interval: float = ..., logScreenshot: bool | None = ..., _pause: bool = ... ) -> None: ... -def hold(keys: str | Iterable[str], logScreenshot: bool | None = ..., _pause: bool = ...) -> Generator[None, None, None]: ... +def hold(keys: str | Iterable[str], logScreenshot: bool | None = ..., _pause: bool = ...) -> contextlib._GeneratorContextManager[None]: ... def typewrite( message: str | Sequence[str], interval: float = ..., logScreenshot: bool | None = ..., _pause: bool = ... ) -> None: ... From 303b474e6769ee8a3a9bf29a9ae45b51d3483303 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 3 Sep 2022 11:36:56 +0000 Subject: [PATCH 13/13] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stubs/PyAutoGUI/pyautogui/__init__.pyi | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/stubs/PyAutoGUI/pyautogui/__init__.pyi b/stubs/PyAutoGUI/pyautogui/__init__.pyi index 2408139a33df..f5ca56afcfe5 100644 --- a/stubs/PyAutoGUI/pyautogui/__init__.pyi +++ b/stubs/PyAutoGUI/pyautogui/__init__.pyi @@ -225,7 +225,9 @@ def keyUp(key: str, logScreenshot: bool | None = ..., _pause: bool = ...) -> Non def press( keys: str | Iterable[str], presses: int = ..., interval: float = ..., logScreenshot: bool | None = ..., _pause: bool = ... ) -> None: ... -def hold(keys: str | Iterable[str], logScreenshot: bool | None = ..., _pause: bool = ...) -> contextlib._GeneratorContextManager[None]: ... +def hold( + keys: str | Iterable[str], logScreenshot: bool | None = ..., _pause: bool = ... +) -> contextlib._GeneratorContextManager[None]: ... def typewrite( message: str | Sequence[str], interval: float = ..., logScreenshot: bool | None = ..., _pause: bool = ... ) -> None: ...