-
Notifications
You must be signed in to change notification settings - Fork 310
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: implement base classes for credentials and request sessions #1551
Conversation
🤖 I detect that the PR title and the commit message differ and there's only one commit. To use the PR title for the commit history, you can use Github's automerge feature with squashing, or use -- conventional-commit-lint bot |
6d0d1a4
to
c22119b
Compare
…hub.com/googleapis/google-auth-library-python into implement-base-requests-and-credentials
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.
LGTM, but get sign-off from auth team.
Quick observation: When refactoring file contents into a new file but still keeping the old file, it is helpful to reviewers if you can make the new file share the old file's previous history, so reviewers can see the diff's between the old file and the new as well as between the the old file's previous version and new version. Instructions are here: https://stackoverflow.com/a/44036771/23828460 (also see https://www.mankier.com/1/git-cp#Synopsis)
No need to do it now after the fact, but keep it in mind for future refactorings.
google/auth/_credentials_base.py
Outdated
headers["authorization"] = "Bearer {}".format( | ||
_helpers.from_bytes(token or self.token) | ||
) | ||
"""Trust boundary value will be a cached value from global lookup. |
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 realize this was in the original file, but it's weird having a string floating as a comment rather than a proper Python comment.
_DEFAULT_TIMEOUT = 120 # in second | ||
|
||
|
||
class _BaseAuthorizedSession(metaclass=abc.ABCMeta): |
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.
My thoughts are similar here re:codesharing. Since the async code is a "colored" function I think it's safe to assume that the sync code and async code should never be in the same callstack.
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.
In terms of the async
semantics, yes that is a valid consideration. But there are still common parts of the logic are re-used between sync and async and those would make sense to consider factoring out. (I think in the rant you linked to, that corresponds to the "blue" functions.)
…hub.com/googleapis/google-auth-library-python into implement-base-requests-and-credentials
…hub.com/googleapis/google-auth-library-python into implement-base-requests-and-credentials
|
…hub.com/googleapis/google-auth-library-python into implement-base-requests-and-credentials
This PR implements base classes for credentials and request sessions to capture the common logic between synchronous and asynchronous code.