From 608b99186da783460609a76195dc168badf5b682 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Mon, 21 Nov 2022 12:45:14 +0300 Subject: [PATCH 1/5] Mark pynput as completed --- stubs/pynput/@tests/stubtest_allowlist.txt | 9 +++++++++ stubs/pynput/METADATA.toml | 3 +++ 2 files changed, 12 insertions(+) diff --git a/stubs/pynput/@tests/stubtest_allowlist.txt b/stubs/pynput/@tests/stubtest_allowlist.txt index b7f3db650225..e80f48017cdc 100644 --- a/stubs/pynput/@tests/stubtest_allowlist.txt +++ b/stubs/pynput/@tests/stubtest_allowlist.txt @@ -5,3 +5,12 @@ pynput.mouse.Controller.__init__ pynput.keyboard.Controller._Key pynput.keyboard._base.Controller._Key pynput.keyboard._dummy.Controller._Key + +# Platform specific private utils: +pynput._util.xorg_keysyms +pynput._util.xorg +pynput._util.win32_vks +pynput._util.win32 +pynput._util.uinput +pynput._util.darwin_vks +pynput._util.darwin diff --git a/stubs/pynput/METADATA.toml b/stubs/pynput/METADATA.toml index ef796600725e..b32ddc518a14 100644 --- a/stubs/pynput/METADATA.toml +++ b/stubs/pynput/METADATA.toml @@ -1 +1,4 @@ version = "1.7.*" + +[tool.stubtest] +ignore_missing_stub = false From 334efcaf649d7fa0ebfa80485cb35149820d33aa Mon Sep 17 00:00:00 2001 From: sobolevn Date: Mon, 21 Nov 2022 12:49:33 +0300 Subject: [PATCH 2/5] Try running on all platforms --- stubs/pynput/METADATA.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/stubs/pynput/METADATA.toml b/stubs/pynput/METADATA.toml index b32ddc518a14..63f39df101d0 100644 --- a/stubs/pynput/METADATA.toml +++ b/stubs/pynput/METADATA.toml @@ -2,3 +2,4 @@ version = "1.7.*" [tool.stubtest] ignore_missing_stub = false +platforms = ["linux", "darwin", "win32"] From 4a5d3284ef9e32282e69ce7c4f0496274b223f89 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Mon, 21 Nov 2022 13:36:24 +0300 Subject: [PATCH 3/5] Add platform specific stubs --- stubs/pynput/@tests/stubtest_allowlist.txt | 3 - .../@tests/stubtest_allowlist_linux.txt | 2 + .../@tests/stubtest_allowlist_win32.txt | 2 + stubs/pynput/pynput/keyboard/_base.pyi | 13 +++++ stubs/pynput/pynput/mouse/_base.pyi | 55 +++++++++++++++++++ 5 files changed, 72 insertions(+), 3 deletions(-) create mode 100644 stubs/pynput/@tests/stubtest_allowlist_linux.txt create mode 100644 stubs/pynput/@tests/stubtest_allowlist_win32.txt diff --git a/stubs/pynput/@tests/stubtest_allowlist.txt b/stubs/pynput/@tests/stubtest_allowlist.txt index e80f48017cdc..b8b3200c6d36 100644 --- a/stubs/pynput/@tests/stubtest_allowlist.txt +++ b/stubs/pynput/@tests/stubtest_allowlist.txt @@ -1,6 +1,3 @@ -# These __init__ methods have *args, **kwargs arguments on some platforms, but not others -pynput.keyboard.Controller.__init__ -pynput.mouse.Controller.__init__ # stubtest issues with non-`type` metaclasses, see https://github.com/python/mypy/issues/13316 pynput.keyboard.Controller._Key pynput.keyboard._base.Controller._Key diff --git a/stubs/pynput/@tests/stubtest_allowlist_linux.txt b/stubs/pynput/@tests/stubtest_allowlist_linux.txt new file mode 100644 index 000000000000..99b195507bcc --- /dev/null +++ b/stubs/pynput/@tests/stubtest_allowlist_linux.txt @@ -0,0 +1,2 @@ +# These __init__ methods have *args, **kwargs arguments on some platforms, but not others +pynput.keyboard.Controller.__init__ diff --git a/stubs/pynput/@tests/stubtest_allowlist_win32.txt b/stubs/pynput/@tests/stubtest_allowlist_win32.txt new file mode 100644 index 000000000000..99b195507bcc --- /dev/null +++ b/stubs/pynput/@tests/stubtest_allowlist_win32.txt @@ -0,0 +1,2 @@ +# These __init__ methods have *args, **kwargs arguments on some platforms, but not others +pynput.keyboard.Controller.__init__ diff --git a/stubs/pynput/pynput/keyboard/_base.pyi b/stubs/pynput/pynput/keyboard/_base.pyi index d930c6654b29..2c77e9d215d0 100644 --- a/stubs/pynput/pynput/keyboard/_base.pyi +++ b/stubs/pynput/pynput/keyboard/_base.pyi @@ -1,5 +1,6 @@ import contextlib import enum +import sys from _typeshed import Self from collections.abc import Callable, Iterable, Iterator from typing import Any, ClassVar @@ -61,6 +62,11 @@ class Key(enum.Enum): f18: int f19: int f20: int + if sys.platform == "win32": + f21: int + f22: int + f23: int + f24: int home: int left: int page_down: int @@ -89,6 +95,13 @@ class Controller: _KeyCode: ClassVar[type[KeyCode]] # undocumented _Key: ClassVar[type[Key]] # undocumented + if sys.platform == "linux": + CTRL_MASK: ClassVar[int] + SHIFT_MASK: ClassVar[int] + + @property + def keyboard_mapping(self) -> dict[int, int]: ... + class InvalidKeyException(Exception): ... class InvalidCharacterException(Exception): ... diff --git a/stubs/pynput/pynput/mouse/_base.pyi b/stubs/pynput/pynput/mouse/_base.pyi index 181dea5a0ca5..dae183d15307 100644 --- a/stubs/pynput/pynput/mouse/_base.pyi +++ b/stubs/pynput/pynput/mouse/_base.pyi @@ -1,4 +1,5 @@ import enum +import sys from _typeshed import Self from collections.abc import Callable from types import TracebackType @@ -11,6 +12,37 @@ class Button(enum.Enum): left: int middle: int right: int + if sys.platform == "linux": + button8: int + button9: int + button10: int + button11: int + button12: int + button13: int + button14: int + button15: int + button16: int + button17: int + button18: int + button19: int + button20: int + button21: int + button22: int + button23: int + button24: int + button25: int + button26: int + button27: int + button28: int + button29: int + button30: int + scroll_down: int + scroll_left: int + scroll_right: int + scroll_up: int + if sys.platform == "win32": + x1: int + x2: int class Controller: def __init__(self) -> None: ... @@ -29,6 +61,29 @@ class Controller: ) -> None: ... class Listener(AbstractListener): + if sys.platform == "win32": + WM_LBUTTONDOWN: int + WM_LBUTTONUP: int + WM_MBUTTONDOWN: int + WM_MBUTTONUP: int + WM_MOUSEMOVE: int + WM_MOUSEWHEEL: int + WM_MOUSEHWHEEL: int + WM_RBUTTONDOWN: int + WM_RBUTTONUP: int + WM_XBUTTONDOWN: int + WM_XBUTTONUP: int + + MK_XBUTTON1: int + MK_XBUTTON2: int + + XBUTTON1: int + XBUTTON2: int + + CLICK_BUTTONS: dict[int, tuple[Button, bool]] + X_BUTTONS: dict[int, dict[int, tuple[Button, bool]]] + SCROLL_BUTTONS: dict[int, tuple[int, int]] + def __init__( self, on_move: Callable[[int, int], bool | None] | None = ..., From bffa38ad37ed6c960e24a9fad5af8a9aab47fb83 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Mon, 21 Nov 2022 13:41:26 +0300 Subject: [PATCH 4/5] Fix CI --- stubs/pynput/@tests/stubtest_allowlist.txt | 3 +++ stubs/pynput/pynput/keyboard/_base.pyi | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/stubs/pynput/@tests/stubtest_allowlist.txt b/stubs/pynput/@tests/stubtest_allowlist.txt index b8b3200c6d36..0fa0e5d5a8c8 100644 --- a/stubs/pynput/@tests/stubtest_allowlist.txt +++ b/stubs/pynput/@tests/stubtest_allowlist.txt @@ -1,3 +1,6 @@ +# These __init__ methods have *args, **kwargs arguments on some platforms, but not others +pynput.mouse.Controller.__init__ + # stubtest issues with non-`type` metaclasses, see https://github.com/python/mypy/issues/13316 pynput.keyboard.Controller._Key pynput.keyboard._base.Controller._Key diff --git a/stubs/pynput/pynput/keyboard/_base.pyi b/stubs/pynput/pynput/keyboard/_base.pyi index 2c77e9d215d0..0ab78d393a92 100644 --- a/stubs/pynput/pynput/keyboard/_base.pyi +++ b/stubs/pynput/pynput/keyboard/_base.pyi @@ -99,9 +99,6 @@ class Controller: CTRL_MASK: ClassVar[int] SHIFT_MASK: ClassVar[int] - @property - def keyboard_mapping(self) -> dict[int, int]: ... - class InvalidKeyException(Exception): ... class InvalidCharacterException(Exception): ... From 6d65db6b88cd83157d30903ed7f7aa1c5a6b7f71 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Mon, 21 Nov 2022 13:45:46 +0300 Subject: [PATCH 5/5] Fix CI --- stubs/pynput/@tests/stubtest_allowlist_linux.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/stubs/pynput/@tests/stubtest_allowlist_linux.txt b/stubs/pynput/@tests/stubtest_allowlist_linux.txt index 99b195507bcc..6a32bbd42136 100644 --- a/stubs/pynput/@tests/stubtest_allowlist_linux.txt +++ b/stubs/pynput/@tests/stubtest_allowlist_linux.txt @@ -1,2 +1,5 @@ # These __init__ methods have *args, **kwargs arguments on some platforms, but not others pynput.keyboard.Controller.__init__ + +# Platform specific implementation detail: +pynput.keyboard.Controller.keyboard_mapping