Skip to content

Commit

Permalink
Merge pull request #598 from jaraco/bugfix/596
Browse files Browse the repository at this point in the history
Apply workaround for decoratated function unrecognized
  • Loading branch information
jaraco committed Sep 17, 2022
2 parents 6466e1e + d666c5c commit f9142e2
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
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)

0 comments on commit f9142e2

Please sign in to comment.