-
-
Notifications
You must be signed in to change notification settings - Fork 307
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
Support username and password from keyring #1734
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry that i missed this aspect back then. from looking at Github's web ui this lgtm. @ofek, would it be of help for you if i had a closer look with an IDE on this?
Yes please |
tests/utils/test_auth.py
Outdated
class MockKeyring: | ||
@staticmethod | ||
def get_credential(*_): | ||
class Credential: | ||
username = 'gat' | ||
|
||
return Credential() | ||
|
||
@staticmethod | ||
def get_password(*_): | ||
return 'guido' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i have no strong opinion on this, but it would imo make sense to
a) realize this as a test fixture that is automatically used on all tests in this module.
b) add the password
attribute to the Credential
dummy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review. Good idea :)
@@ -72,6 +73,12 @@ def __get_username(self) -> str: | |||
self.__username_was_read = True | |||
return self._app.prompt(f"Username for '{self._repo_config['url']}' [__token__]") or '__token__' | |||
|
|||
def _read_keyring(self) -> str | None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this could also store the __password
property as i'm assuming that using a username from this credentials source doesn't make sense with a password from another source.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, no need to run read the password again if we already have it. I pushed my changes. Thanks for the review
a0e624f
to
1056b7b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, beside the minor import detail this looks good to merge.
(don't know whether the UI changed or it's circumstances. i can't mark the inline comment threads as resolved. they are.)
@@ -1,5 +1,7 @@ | |||
from __future__ import annotations | |||
|
|||
import keyring |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm pretty sure @ofek prefers that to be imported only when it's needed in _read_keyring
.
Hello everyone,
this brings back the enhancement added with #713 that broke with f59508b.
Had minor problems getting the tests to run because https://hatch.pypa.io/latest/community/contributing/ is outdated, but https://github.com/pypa/hatch/blob/master/docs/community/contributing.md worked 👍.