From a447ad0f1a934327e619e8df04efb757129103a8 Mon Sep 17 00:00:00 2001 From: Xiddoc <46180972+Xiddoc@users.noreply.github.com> Date: Mon, 17 Feb 2025 12:31:50 +0200 Subject: [PATCH] Add pyperclip stubs (#13502) --- stubs/pyperclip/@tests/stubtest_allowlist.txt | 1 + stubs/pyperclip/METADATA.toml | 6 +++++ stubs/pyperclip/pyperclip/__init__.pyi | 24 +++++++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 stubs/pyperclip/@tests/stubtest_allowlist.txt create mode 100644 stubs/pyperclip/METADATA.toml create mode 100644 stubs/pyperclip/pyperclip/__init__.pyi diff --git a/stubs/pyperclip/@tests/stubtest_allowlist.txt b/stubs/pyperclip/@tests/stubtest_allowlist.txt new file mode 100644 index 000000000..096a89722 --- /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 000000000..d8fd275f4 --- /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 000000000..4d2947e84 --- /dev/null +++ b/stubs/pyperclip/pyperclip/__init__.pyi @@ -0,0 +1,24 @@ +__all__ = ["copy", "paste", "set_clipboard", "determine_clipboard"] + +from collections.abc import Callable +from typing import Literal +from typing_extensions import TypeAlias + +class PyperclipException(RuntimeError): ... + +class PyperclipWindowsException(PyperclipException): + def __init__(self, message: str) -> None: ... + +class PyperclipTimeoutException(PyperclipException): ... + +_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]: ... +def is_available() -> bool: ...