Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply workaround for decoratated function unrecognized #598

Merged
merged 4 commits into from Sep 17, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGES.rst
@@ -1,3 +1,8 @@
v23.9.3
-------

* #596: Add workaround for devpi_client hook with wrapped implementation.

v23.9.2
-------

Expand Down
2 changes: 0 additions & 2 deletions conftest.py
Expand Up @@ -19,5 +19,3 @@ def macos_api_ignore():


collect_ignore.extend(['keyring/backends/macOS/api.py'] * macos_api_ignore())

collect_ignore.append('keyring/devpi_client.py')
25 changes: 20 additions & 5 deletions keyring/devpi_client.py
@@ -1,19 +1,34 @@
import contextlib
import functools

from pluggy import HookimplMarker
import pluggy

import keyring
from keyring.errors import KeyringError
import keyring.errors


hookimpl = HookimplMarker("devpiclient")
hookimpl = pluggy.HookimplMarker("devpiclient")


# https://github.com/jaraco/jaraco.context/blob/c3a9b739/jaraco/context.py#L205
suppress = type('suppress', (contextlib.suppress, contextlib.ContextDecorator), {})


def restore_signature(func):
# workaround for pytest-dev/pluggy#358
@functools.wraps(func)
def wrapper(url, username):
return func(url, username)

return wrapper


@hookimpl()
@suppress(KeyringError)
@restore_signature
@suppress(keyring.errors.KeyringError)
def devpiclient_get_password(url, username):
"""
>>> pluggy._hooks.varnames(devpiclient_get_password)
(('url', 'username'), ())
>>>
"""
return keyring.get_password(url, username)