Skip to content

Add pyperclip stubs - #13502

Merged
srittau merged 9 commits into
python:mainfrom
Xiddoc:add-pyperclip-and-clipboard-stubs
Feb 17, 2025
Merged

srittau merged 9 commits into
python:mainfrom
Xiddoc:add-pyperclip-and-clipboard-stubs

Conversation

@Xiddoc

@Xiddoc Xiddoc commented Feb 15, 2025

Copy link
Copy Markdown
Contributor

The pyperclip library is a lovely package which exposes a simple API for interacting with the OS clipboard. It seems to be unfortunately unmaintained, and it doesn't seem like types will be added soon.

The clipboard library is a re-package of pyperclip, but with a more explicit name (it just exposes the pyperclip API).

Both clipboard and pyperclip amass almost 5 million downloads monthly. It's about time we give them proper typing.

@github-actions

This comment has been minimized.

1 similar comment
@github-actions

This comment has been minimized.

@Xiddoc
Xiddoc force-pushed the add-pyperclip-and-clipboard-stubs branch from b387e6a to 2748860 Compare February 15, 2025 12:42
@github-actions

This comment has been minimized.

@Xiddoc
Xiddoc force-pushed the add-pyperclip-and-clipboard-stubs branch from 4d6203b to 360e2f1 Compare February 15, 2025 13:06
@github-actions

This comment has been minimized.

1 similar comment
@github-actions

This comment has been minimized.

@Xiddoc
Xiddoc force-pushed the add-pyperclip-and-clipboard-stubs branch from c83c29b to e2fc504 Compare February 15, 2025 13:37
@github-actions

This comment has been minimized.

@Xiddoc
Xiddoc force-pushed the add-pyperclip-and-clipboard-stubs branch from e2fc504 to 78bcdbf Compare February 15, 2025 14:39
@github-actions

This comment has been minimized.

@Xiddoc Xiddoc mentioned this pull request Feb 15, 2025
@Xiddoc

Xiddoc commented Feb 15, 2025

Copy link
Copy Markdown
Contributor Author

I've separated clipboard to a separate PR (#13503 )as it depends on pyperclip having types.

Xiddoc pushed a commit to Xiddoc/typeshed that referenced this pull request Feb 15, 2025
@Xiddoc Xiddoc changed the title Add pyperclip and clipboard stubs Add pyperclip stubs Feb 15, 2025
@github-actions

This comment has been minimized.

1 similar comment
@github-actions

This comment has been minimized.

Comment thread stubs/pyperclip/pyperclip/__init__.pyi Outdated
def __call__(self, *args: Any) -> Any: ...

# Wrapper for ctypes calls, should not be exposed to the developer
class CheckedCall:

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.

I think we should delete this from the stubs, because as the comment says, you shouldn't do from pyperclip import CheckedCall.

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.

Removed, thanks for the comment

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!

@Xiddoc
Xiddoc force-pushed the add-pyperclip-and-clipboard-stubs branch from db8850d to 4350fd4 Compare February 16, 2025 20:23
@github-actions

This comment has been minimized.

@Xiddoc
Xiddoc force-pushed the add-pyperclip-and-clipboard-stubs branch from 4350fd4 to b6b1490 Compare February 16, 2025 20:35
@github-actions

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@srittau srittau left a comment

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.

Thanks!

@srittau
srittau merged commit a447ad0 into python:main Feb 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants