diff --git a/CHANGES.rst b/CHANGES.rst index cc050eaf..3259ca83 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,3 +1,8 @@ +v23.9.3 +------- + +* #596: Add workaround for devpi_client hook with wrapped implementation. + v23.9.2 ------- diff --git a/conftest.py b/conftest.py index ab0021e0..2dce06d4 100644 --- a/conftest.py +++ b/conftest.py @@ -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') diff --git a/keyring/devpi_client.py b/keyring/devpi_client.py index dfc02452..6a2b1898 100644 --- a/keyring/devpi_client.py +++ b/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)