diff --git a/stubs/clipboard/METADATA.toml b/stubs/clipboard/METADATA.toml new file mode 100644 index 000000000000..2e4cec2f3723 --- /dev/null +++ b/stubs/clipboard/METADATA.toml @@ -0,0 +1,6 @@ +version = "0.0.*" +upstream_repository = "https://github.com/terryyin/clipboard" +requires = ["pyperclip"] + +[tool.stubtest] +platforms = ["win32", "linux", "darwin"] diff --git a/stubs/clipboard/clipboard.pyi b/stubs/clipboard/clipboard.pyi new file mode 100644 index 000000000000..86e0b96acaca --- /dev/null +++ b/stubs/clipboard/clipboard.pyi @@ -0,0 +1 @@ +from pyperclip import copy as copy, paste as paste diff --git a/stubs/pyperclip/@tests/stubtest_allowlist.txt b/stubs/pyperclip/@tests/stubtest_allowlist.txt new file mode 100644 index 000000000000..096a897229c8 --- /dev/null +++ b/stubs/pyperclip/@tests/stubtest_allowlist.txt @@ -0,0 +1 @@ +pyperclip.__main__ diff --git a/stubs/pyperclip/METADATA.toml b/stubs/pyperclip/METADATA.toml new file mode 100644 index 000000000000..d8fd275f4016 --- /dev/null +++ b/stubs/pyperclip/METADATA.toml @@ -0,0 +1,6 @@ +version = "1.9.*" +upstream_repository = "https://github.com/asweigart/pyperclip" + +[tool.stubtest] +platforms = ["win32", "linux", "darwin"] +apt_dependencies = ["xclip"] diff --git a/stubs/pyperclip/pyperclip/__init__.pyi b/stubs/pyperclip/pyperclip/__init__.pyi new file mode 100644 index 000000000000..1b16e3de8f85 --- /dev/null +++ b/stubs/pyperclip/pyperclip/__init__.pyi @@ -0,0 +1,32 @@ +__all__ = ["copy", "paste", "set_clipboard", "determine_clipboard"] + +from collections.abc import Callable +from typing import Any, Literal, Protocol +from typing_extensions import TypeAlias + +class PyperclipException(RuntimeError): ... + +class PyperclipWindowsException(PyperclipException): + def __init__(self, message: str) -> None: ... + +class PyperclipTimeoutException(PyperclipException): ... + +class _WinDLLUser32Function(Protocol): + def __call__(self, *args: Any) -> Any: ... + +# Wrapper for ctypes calls, should not be exposed to the developer +class CheckedCall: + def __init__(self, f: _WinDLLUser32Function) -> None: ... + def __call__(self, *args: Any) -> Any: ... + def __setattr__(self, key: str, value: Any) -> None: ... + +_ClipboardMechanismName: TypeAlias = Literal[ + "pbcopy", "pyobjc", "qt", "xclip", "xsel", "wl-clipboard", "klipper", "windows", "no" +] +_ClipboardCopyMechanism: TypeAlias = Callable[[str], None] +_ClipboardPasteMechanism: TypeAlias = Callable[[], str] + +def copy(text: str) -> None: ... +def paste() -> str: ... +def set_clipboard(clipboard: _ClipboardMechanismName) -> None: ... +def determine_clipboard() -> tuple[_ClipboardCopyMechanism, _ClipboardPasteMechanism]: ...