-
-
Notifications
You must be signed in to change notification settings - Fork 64
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
feat: KeyringSettingsSource
class to load keyring variables
#140
base: main
Are you sure you want to change the base?
Conversation
KeyringSettingsSource
class to load keyring variables
Thanks @lmmx for the proposal and the PR 🙏
You can add
We have
I think you can raise a I think we need to have:
|
TODO list
No comments 👍
Optional dependency importThe example of
Settings source edit
I hadn't thought of that, I just added it and let it default to Mac supportOS X has a TestsI used this as a dependency in an early stage project This already helped me uncover and fix bugs in the implementation (in case sensitivity handling), so testing should be easy to build off of this. |
I thought about the way pydantic is importing optional dependencies and as I recalled seeing a cleaner way in pandas, I reviewed their approach, The rest of the comment explains why I'm choosing a combination of both, if it's of interest! Theirs is not type equivalent: in pydantic the TYPE_CHECKING block ensures the type of the module name is always an imported module's type, whereas in pandas the return type of the helper function is Theirs is however cleaner: the import site is not required to be wrapped in pydantic's approach uses We can parameterise In this case I would need to add multiple import lines to the block: if TYPE_CHECKING:
import keyring
from keyring.backends.SecretService import Keyring as SecretServiceKeyring
else:
keyring = None
SecretServiceKeyring = None as opposed to one line, without a keyring, SecretServiceKeyring = import_optional_dependency("keyring", "keyring.backends.SecretService.Keyring") I'll put it together and fall back to the template of the single-module import function if I've misjudged part of this or if you don't like the idea. |
May I ask what the status of this PR is? |
Proposal
PR to fulfill the feature proposal:
keyring
encrypted credential storage #139Details
keyring_backend
is provided, and behaves similarly to theenv_file
: if the named backend is not found, nothing is loaded. If not specified, the default backend is used.mypy linting
The CI workflow does not install the project dependencies so the linting step is failing.
If I
pip install -e[keyring]
the mypy error is resolved.Due to incorrectly cast annotations in the source package I had to use
cast
to get the correct annotation. Not all backends seem to support the enumeration of all keys in the keyring, so to begin with I have restricted the implementation to theSecretService
backend (Linux).Request for review
try
/except ImportError: pass
acceptable? An alternative would be to set a variable that could be used to gate the calling of thekeyring
module.