Closed altendky closed 2 months ago
I'd like not to have to repeat the viability check for each and every operation. Adding this change here implies that a similar change should also be added to set_password
and delete_password
(and get_credential
, though that is handled as it shares _get_password
), but also to those methods on every other backend.
The designed intention is that one will only construct an instance of a KeyringBackend
subclass if the subclass.viable
is True
. In your environment, I'd expect WinVaultKeyring.viable
to be False
.
Maybe it would make sense in KeyringBackend.__init__()
to assert viability. Something like:
diff --git a/keyring/backend.py b/keyring/backend.py
index 12c8b7f..f60c270 100644
--- a/keyring/backend.py
+++ b/keyring/backend.py
@@ -46,6 +46,8 @@ class KeyringBackend(metaclass=KeyringBackendMeta):
"""
def __init__(self):
+ # assert viability of the backend
+ self.priority
self.set_properties_from_env()
@properties.classproperty
Unfortunately, that diff causes failures with infinite recursion, so it's not as simple as that.
Before we attempt to tackle preventing construction of non-viable backends, let's first figure out why a non-viable backend is getting constructed and whether that's a use-case worth supporting.
Please re-file as an issue and elaborate on the investigation as to what conditions lead to the failure.
Separately, I need to figure out how I'm getting into this state, but from the other code it looks like this guard and explicit exception are the intended pattern for handling missing imports. Though, it does seem that the traceback I am getting would be more useful. But, I'll offer this up for consideration anyways.
https://github.com/Chia-Network/chia-blockchain/actions/runs/9372142688/job/25803038861?pr=18112#step:16:877