Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

stollero
Copy link

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 👍.

Copy link
Contributor

@funkyfuture funkyfuture left a 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?

@ofek
Copy link
Collaborator

ofek commented Nov 7, 2024

Yes please

Comment on lines 49 to 59
class MockKeyring:
@staticmethod
def get_credential(*_):
class Credential:
username = 'gat'

return Credential()

@staticmethod
def get_password(*_):
return 'guido'
Copy link
Contributor

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.

Copy link
Author

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:
Copy link
Contributor

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.

Copy link
Author

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

Copy link
Contributor

@funkyfuture funkyfuture left a 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
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants