-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Added missing types #16666
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
Draft
Tesla2000
wants to merge
1
commit into
googleapis:main
Choose a base branch
from
Tesla2000:python-interface
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Added missing types #16666
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,9 @@ | |
| import inspect | ||
|
|
||
| from google.auth import credentials | ||
| from google.auth.transport import Request as _Request, Request as _Request | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| from collections.abc import Mapping, Sequence | ||
| from google.auth.credentials import AnonymousCredentials, Credentials, CredentialsWithQuotaProject, ReadOnlyScoped, Scoped, Signing | ||
|
|
||
|
|
||
| class Credentials(credentials.Credentials, metaclass=abc.ABCMeta): | ||
|
|
@@ -41,7 +44,7 @@ class Credentials(credentials.Credentials, metaclass=abc.ABCMeta): | |
| with modifications such as :meth:`ScopedCredentials.with_scopes`. | ||
| """ | ||
|
|
||
| async def before_request(self, request, method, url, headers): | ||
| async def before_request(self, request: _Request, method: str, url: str, headers: Mapping[str, str]) -> None: | ||
| """Performs credential-specific before request logic. | ||
|
|
||
| Refreshes the credentials if necessary, then calls :meth:`apply` to | ||
|
|
@@ -141,7 +144,7 @@ class Scoped(credentials.Scoped): | |
| """ | ||
|
|
||
|
|
||
| def with_scopes_if_required(credentials, scopes): | ||
| def with_scopes_if_required(credentials: Credentials, scopes: Sequence[str]) -> Credentials: | ||
| """Creates a copy of the credentials with scopes if scoping is required. | ||
|
|
||
| This helper function is useful when you do not know (or care to know) the | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,11 +22,13 @@ | |
| import json | ||
| import logging | ||
| import os | ||
| from typing import Optional, Sequence, TYPE_CHECKING | ||
| from typing import Any, Optional, Sequence, TYPE_CHECKING | ||
| import warnings | ||
|
|
||
| from google.auth import environment_vars | ||
| from google.auth import exceptions | ||
| import collections.abc | ||
| from google.auth.api_key import Credentials as _ApiKeyCredentials | ||
|
|
||
| if TYPE_CHECKING: # pragma: NO COVER | ||
| import google.auth.credentials.Credentials # type: ignore | ||
|
|
@@ -128,8 +130,8 @@ def _warn_about_generic_load_method(method_name): # pragma: NO COVER | |
|
|
||
|
|
||
| def load_credentials_from_file( | ||
| filename, scopes=None, default_scopes=None, quota_project_id=None, request=None | ||
| ): | ||
| filename: str, scopes: collections.abc.Sequence[str] | None=None, default_scopes: collections.abc.Sequence[str] | None=None, quota_project_id: str | None=None, request: Request | None=None | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| ) -> tuple[Credentials, str | None]: | ||
| """Loads Google credentials from a file. | ||
|
|
||
| The credentials file must be a service account key, stored authorized | ||
|
|
@@ -193,8 +195,8 @@ def load_credentials_from_file( | |
|
|
||
|
|
||
| def load_credentials_from_dict( | ||
| info, scopes=None, default_scopes=None, quota_project_id=None, request=None | ||
| ): | ||
| info: collections.abc.Mapping[str, Any], scopes: collections.abc.Sequence[str] | None=None, default_scopes: collections.abc.Sequence[str] | None=None, quota_project_id: str | None=None, request: Request | None=None | ||
| ) -> tuple[Credentials, str | None]: | ||
| """Loads Google credentials from a dict. | ||
|
|
||
| The credentials file must be a service account key, stored authorized | ||
|
|
@@ -568,7 +570,7 @@ def _get_gdch_service_account_credentials(filename, info): | |
| return credentials, info.get("project") | ||
|
|
||
|
|
||
| def get_api_key_credentials(key): | ||
| def get_api_key_credentials(key: str) -> _ApiKeyCredentials: | ||
| """Return credentials with the given API key.""" | ||
| from google.auth import api_key | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The type hint Hashable is used but not imported. It should be imported from collections.abc.