Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions stubs/pyperclip/@tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pyperclip.__main__
6 changes: 6 additions & 0 deletions stubs/pyperclip/METADATA.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version = "1.9.*"
upstream_repository = "https://github.com/asweigart/pyperclip"

[tool.stubtest]
platforms = ["win32", "linux", "darwin"]
apt_dependencies = ["xclip"]
24 changes: 24 additions & 0 deletions stubs/pyperclip/pyperclip/__init__.pyi
Original file line number Diff line number Diff line change
@@ -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]: ...

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is also is_available(), and an example of using it in the module docstring:

Suggested change
def determine_clipboard() -> tuple[_ClipboardCopyMechanism, _ClipboardPasteMechanism]: ...
def determine_clipboard() -> tuple[_ClipboardCopyMechanism, _ClipboardPasteMechanism]: ...
def is_available() -> bool: ... # undocumented

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added!

def is_available() -> bool: ...