Skip to content

Commit ef4e52d

Browse files
authored
PyAutoGUI: Use types from PyScreeze (#8824)
1 parent 493e35b commit ef4e52d

File tree

2 files changed

+11
-161
lines changed

2 files changed

+11
-161
lines changed

stubs/PyAutoGUI/METADATA.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
version = "0.9.*"
2-
requires = ["types-Pillow"]
2+
requires = ["types-PyScreeze", "types-Pillow"]

stubs/PyAutoGUI/pyautogui/__init__.pyi

Lines changed: 10 additions & 160 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
import contextlib
2-
from _typeshed import Incomplete
3-
from collections.abc import Callable, Generator, Iterable, Sequence
2+
from collections.abc import Callable, Iterable, Sequence
43
from datetime import datetime
5-
from typing import NamedTuple, SupportsFloat, SupportsInt, TypeVar, overload
4+
from typing import NamedTuple, SupportsInt, TypeVar
65
from typing_extensions import ParamSpec, SupportsIndex, TypeAlias
76

8-
from PIL import Image
7+
from pyscreeze import (
8+
locate as locate,
9+
locateAll as locateAll,
10+
locateAllOnScreen as locateAllOnScreen,
11+
locateCenterOnScreen as locateCenterOnScreen,
12+
locateOnScreen as locateOnScreen,
13+
locateOnWindow as locateOnWindow,
14+
)
915

1016
class PyAutoGUIException(Exception): ...
1117
class FailSafeException(PyAutoGUIException): ...
@@ -14,164 +20,8 @@ class ImageNotFoundException(PyAutoGUIException): ...
1420
_P = ParamSpec("_P")
1521
_R = TypeVar("_R")
1622
_NormalizeableXArg: TypeAlias = str | SupportsInt | Sequence[SupportsInt]
17-
_Unused: TypeAlias = object
18-
19-
# TODO: cv2.Mat is not available as a type yet: https://github.com/microsoft/python-type-stubs/issues/211
20-
# cv2.Mat is just an alias for a numpy NDArray, but can't import that either.
21-
_Mat: TypeAlias = Incomplete
22-
23-
class _Box(NamedTuple): # Same as pyscreeze.Box
24-
left: int
25-
top: int
26-
width: int
27-
height: int
2823

2924
def raisePyAutoGUIImageNotFoundException(wrappedFunction: Callable[_P, _R]) -> Callable[_P, _R]: ...
30-
31-
# These functions reuse pyscreeze functions directly.
32-
# TODO: Once pyscreeze is typed, we can alias them to simplify this stub
33-
34-
# _locateAll_opencv
35-
@overload
36-
def locate(
37-
needleImage: str | Image.Image | _Mat,
38-
haystackImage: str | Image.Image | _Mat,
39-
grayscale: bool | None = ...,
40-
limit: _Unused = ...,
41-
region: _Box | None = ...,
42-
step: int = ...,
43-
confidence: SupportsFloat = ...,
44-
) -> _Box | None: ...
45-
46-
# _locateAll_python / _locateAll_pillow
47-
@overload
48-
def locate(
49-
needleImage: str | Image.Image,
50-
haystackImage: str | Image.Image,
51-
grayscale: bool | None = ...,
52-
limit: _Unused = ...,
53-
region: _Box | None = ...,
54-
step: int = ...,
55-
confidence: None = ...,
56-
) -> _Box | None: ...
57-
58-
# _locateAll_opencv
59-
@overload
60-
def locateAll(
61-
needleImage: str | Image.Image | _Mat,
62-
haystackImage: str | Image.Image | _Mat,
63-
grayscale: bool | None = ...,
64-
limit: int = ...,
65-
region: _Box | None = ...,
66-
step: int = ...,
67-
confidence: SupportsFloat = ...,
68-
) -> Generator[_Box, None, None]: ...
69-
70-
# _locateAll_python / _locateAll_pillow
71-
@overload
72-
def locateAll(
73-
needleImage: str | Image.Image,
74-
haystackImage: str | Image.Image,
75-
grayscale: bool | None = ...,
76-
limit: int | None = ...,
77-
region: _Box | None = ...,
78-
step: int = ...,
79-
confidence: None = ...,
80-
) -> Generator[_Box, None, None]: ...
81-
82-
# _locateAll_opencv
83-
@overload
84-
def locateAllOnScreen(
85-
image: str | Image.Image | _Mat,
86-
grayscale: bool | None = ...,
87-
limit: int = ...,
88-
region: _Box | None = ...,
89-
step: int = ...,
90-
confidence: SupportsFloat = ...,
91-
) -> Generator[_Box, None, None]: ...
92-
93-
# _locateAll_python / _locateAll_pillow
94-
@overload
95-
def locateAllOnScreen(
96-
image: str | Image.Image,
97-
grayscale: bool | None = ...,
98-
limit: int | None = ...,
99-
region: _Box | None = ...,
100-
step: int = ...,
101-
confidence: None = ...,
102-
) -> Generator[_Box, None, None]: ...
103-
104-
# _locateAll_opencv
105-
@overload
106-
def locateCenterOnScreen(
107-
image: str | Image.Image | _Mat,
108-
minSearchTime: float,
109-
grayscale: bool | None = ...,
110-
limit: _Unused = ...,
111-
region: _Box | None = ...,
112-
step: int = ...,
113-
confidence: SupportsFloat = ...,
114-
) -> Point | None: ...
115-
116-
# _locateAll_python / _locateAll_pillow
117-
@overload
118-
def locateCenterOnScreen(
119-
image: str | Image.Image,
120-
minSearchTime: float,
121-
grayscale: bool | None = ...,
122-
limit: _Unused = ...,
123-
region: _Box | None = ...,
124-
step: int = ...,
125-
confidence: None = ...,
126-
) -> Point | None: ...
127-
128-
# _locateAll_opencv
129-
@overload
130-
def locateOnScreen(
131-
image: str | Image.Image | _Mat,
132-
minSearchTime: float,
133-
grayscale: bool | None = ...,
134-
limit: _Unused = ...,
135-
region: _Box | None = ...,
136-
step: int = ...,
137-
confidence: SupportsFloat = ...,
138-
) -> _Box | None: ...
139-
140-
# _locateAll_python / _locateAll_pillow
141-
@overload
142-
def locateOnScreen(
143-
image: str | Image.Image,
144-
minSearchTime: float,
145-
grayscale: bool | None = ...,
146-
limit: _Unused = ...,
147-
region: _Box | None = ...,
148-
step: int = ...,
149-
confidence: None = ...,
150-
) -> _Box | None: ...
151-
152-
# _locateAll_opencv
153-
@overload
154-
def locateOnWindow(
155-
image: str | Image.Image | _Mat,
156-
title: str,
157-
grayscale: bool | None = ...,
158-
limit: _Unused = ...,
159-
step: int = ...,
160-
confidence: SupportsFloat = ...,
161-
) -> _Box | None: ...
162-
163-
# _locateAll_python / _locateAll_pillow
164-
@overload
165-
def locateOnWindow(
166-
image: str | Image.Image,
167-
title: str,
168-
grayscale: bool | None = ...,
169-
limit: _Unused = ...,
170-
step: int = ...,
171-
confidence: None = ...,
172-
) -> _Box | None: ...
173-
174-
# end of reused pyscreeze functions
17525
def mouseInfo() -> None: ...
17626
def useImageNotFoundException(value: bool | None = ...) -> None: ...
17727

0 commit comments

Comments
 (0)