Skip to content

Commit 1a99c2b

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
1 parent 3491cf0 commit 1a99c2b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+644
-1249
lines changed

stubs/google-auth/google/auth/__init__.pyi

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ from google.auth._default import (
44
load_credentials_from_file as load_credentials_from_file,
55
)
66

7-
__all__ = [
8-
"default",
9-
"load_credentials_from_file",
10-
"load_credentials_from_dict",
11-
]
7+
__all__ = ["default", "load_credentials_from_file", "load_credentials_from_dict"]
128

139
class Python37DeprecationWarning(DeprecationWarning): ...
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
from typing import Any, Optional
1+
from typing import Any
22

33
CRYPTOGRAPHY_NOT_FOUND_ERROR: str
44

5-
def get_agent_identity_certificate_path() -> Optional[str]: ...
6-
def get_and_parse_agent_identity_certificate() -> Optional[Any]: ...
5+
def get_agent_identity_certificate_path() -> str | None: ...
6+
def get_and_parse_agent_identity_certificate() -> Any | None: ...
77
def parse_certificate(cert_bytes: bytes) -> Any: ...
88
def calculate_certificate_fingerprint(cert: Any) -> str: ...
99
def should_request_bound_token(cert: Any) -> bool: ...
10-
def get_cached_cert_fingerprint(cached_cert: Optional[bytes]) -> str: ...
10+
def get_cached_cert_fingerprint(cached_cert: bytes | None) -> str: ...
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
from typing import Optional
2-
31
CLOUD_SDK_CLIENT_ID: str
42

53
def get_config_path() -> str: ...
64
def get_application_default_credentials_path() -> str: ...
7-
def get_project_id() -> Optional[str]: ...
8-
def get_auth_access_token(account: Optional[str] = None) -> str: ...
5+
def get_project_id() -> str | None: ...
6+
def get_auth_access_token(account: str | None = None) -> str: ...
Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,20 @@
11
import abc
22
from typing import Mapping, Sequence
3+
34
from google.auth import credentials
45
from google.auth.transport import Request as _Request
56

67
class Credentials(credentials.Credentials, metaclass=abc.ABCMeta):
7-
async def before_request(
8-
self,
9-
request: _Request,
10-
method: str,
11-
url: str,
12-
headers: Mapping[str, str],
13-
) -> None: ...
8+
async def before_request(self, request: _Request, method: str, url: str, headers: Mapping[str, str]) -> None: ...
149

15-
class CredentialsWithQuotaProject(
16-
credentials.CredentialsWithQuotaProject, metaclass=abc.ABCMeta
17-
): ...
10+
class CredentialsWithQuotaProject(credentials.CredentialsWithQuotaProject, metaclass=abc.ABCMeta): ...
1811

1912
class AnonymousCredentials(credentials.AnonymousCredentials, Credentials):
20-
...
21-
22-
async def before_request(
23-
self,
24-
request: _Request,
25-
method: str,
26-
url: str,
27-
headers: Mapping[str, str],
28-
) -> None: ...
13+
async def before_request(self, request: _Request, method: str, url: str, headers: Mapping[str, str]) -> None: ...
2914

3015
class ReadOnlyScoped(credentials.ReadOnlyScoped, metaclass=abc.ABCMeta): ...
3116
class Scoped(credentials.Scoped, metaclass=abc.ABCMeta): ...
3217

33-
def with_scopes_if_required(
34-
credentials: "Credentials", scopes: Sequence[str]
35-
) -> "Credentials": ...
18+
def with_scopes_if_required(credentials: Credentials, scopes: Sequence[str]) -> Credentials: ...
3619

37-
class Signing(credentials.Signing, metaclass=abc.ABCMeta):
38-
pass
20+
class Signing(credentials.Signing, metaclass=abc.ABCMeta): ...
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import abc
22
from _typeshed import Incomplete
3-
from google.auth.transport import Request as _TransportRequest
43
from typing import Any, Coroutine
54

5+
from google.auth.transport import Request as _TransportRequest
6+
67
class _BaseCredentials(metaclass=abc.ABCMeta):
78
token: Incomplete
89

910
def __init__(self) -> None: ...
1011
@abc.abstractmethod
11-
def refresh(
12-
self, request: _TransportRequest
13-
) -> None | Coroutine[Any, Any, None]: ...
12+
def refresh(self, request: _TransportRequest) -> None | Coroutine[Any, Any, None]: ...
Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import TYPE_CHECKING, Any, Mapping, Optional, Sequence, Tuple
1+
from typing import TYPE_CHECKING, Any, Mapping, Sequence
22

33
from google.auth.credentials import Credentials as Credentials
44
from google.auth.transport import Request as Request
@@ -8,22 +8,22 @@ if TYPE_CHECKING:
88

99
def load_credentials_from_file(
1010
filename: str,
11-
scopes: Optional[Sequence[str]] = None,
12-
default_scopes: Optional[Sequence[str]] = None,
13-
quota_project_id: Optional[str] = None,
14-
request: Optional[Request] = None,
15-
) -> Tuple[Credentials, Optional[str]]: ...
11+
scopes: Sequence[str] | None = None,
12+
default_scopes: Sequence[str] | None = None,
13+
quota_project_id: str | None = None,
14+
request: Request | None = None,
15+
) -> tuple[Credentials, str | None]: ...
1616
def load_credentials_from_dict(
1717
info: Mapping[str, Any],
18-
scopes: Optional[Sequence[str]] = None,
19-
default_scopes: Optional[Sequence[str]] = None,
20-
quota_project_id: Optional[str] = None,
21-
request: Optional[Request] = None,
22-
) -> Tuple[Credentials, Optional[str]]: ...
23-
def get_api_key_credentials(key: str) -> "_ApiKeyCredentials": ...
18+
scopes: Sequence[str] | None = None,
19+
default_scopes: Sequence[str] | None = None,
20+
quota_project_id: str | None = None,
21+
request: Request | None = None,
22+
) -> tuple[Credentials, str | None]: ...
23+
def get_api_key_credentials(key: str) -> _ApiKeyCredentials: ...
2424
def default(
25-
scopes: Optional[Sequence[str]] = None,
26-
request: Optional[Request] = None,
27-
quota_project_id: Optional[str] = None,
28-
default_scopes: Optional[Sequence[str]] = None,
29-
) -> Tuple[Credentials, Optional[str]]: ...
25+
scopes: Sequence[str] | None = None,
26+
request: Request | None = None,
27+
quota_project_id: str | None = None,
28+
default_scopes: Sequence[str] | None = None,
29+
) -> tuple[Credentials, str | None]: ...
Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
1-
from typing import Optional, Sequence, Tuple
1+
from typing import Sequence
22

33
from google.auth.credentials import Credentials as Credentials
44
from google.auth.transport import Request as _Request
55

66
def load_credentials_from_file(
7-
filename: str,
8-
scopes: Optional[Sequence[str]] = None,
9-
quota_project_id: Optional[str] = None,
10-
) -> Tuple[Credentials, Optional[str]]: ...
7+
filename: str, scopes: Sequence[str] | None = None, quota_project_id: str | None = None
8+
) -> tuple[Credentials, str | None]: ...
119
def default_async(
12-
scopes: Optional[Sequence[str]] = None,
13-
request: Optional[_Request] = None,
14-
quota_project_id: Optional[str] = None,
15-
) -> Tuple[Credentials, Optional[str]]: ...
10+
scopes: Sequence[str] | None = None, request: _Request | None = None, quota_project_id: str | None = None
11+
) -> tuple[Credentials, str | None]: ...

stubs/google-auth/google/auth/_exponential_backoff.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ class _BaseExponentialBackoff:
1313

1414
class ExponentialBackoff(_BaseExponentialBackoff):
1515
def __init__(self, *args: object, **kwargs: object) -> None: ...
16-
def __iter__(self) -> "ExponentialBackoff": ...
16+
def __iter__(self) -> ExponentialBackoff: ...
1717
def __next__(self) -> int: ...
1818

1919
class AsyncExponentialBackoff(_BaseExponentialBackoff):
2020
def __init__(self, *args: object, **kwargs: object) -> None: ...
21-
def __aiter__(self) -> "AsyncExponentialBackoff": ...
21+
def __aiter__(self) -> AsyncExponentialBackoff: ...
2222
async def __anext__(self) -> int: ...
Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import datetime
22
import logging
3-
from typing import Any, Callable, Mapping, Optional, Sequence, Union
3+
from typing import Any, Callable, Mapping, Sequence
44

55
REFRESH_THRESHOLD: datetime.timedelta
66

@@ -9,25 +9,15 @@ def parse_content_type(header_value: str) -> str: ...
99
def utcnow() -> datetime.datetime: ...
1010
def utcfromtimestamp(timestamp: float) -> datetime.datetime: ...
1111
def datetime_to_secs(value: datetime.datetime) -> int: ...
12-
def to_bytes(value: Union[str, bytes], encoding: str = "utf-8") -> bytes: ...
13-
def from_bytes(value: Union[str, bytes]) -> str: ...
14-
def update_query(
15-
url: str, params: Mapping[str, str], remove: Optional[Sequence[str]] = None
16-
) -> str: ...
12+
def to_bytes(value: str | bytes, encoding: str = "utf-8") -> bytes: ...
13+
def from_bytes(value: str | bytes) -> str: ...
14+
def update_query(url: str, params: Mapping[str, str], remove: Sequence[str] | None = None) -> str: ...
1715
def scopes_to_string(scopes: Sequence[str]) -> str: ...
18-
def string_to_scopes(scopes: Union[Sequence[str], str]) -> list[str]: ...
19-
def padded_urlsafe_b64decode(value: Union[str, bytes]) -> bytes: ...
20-
def unpadded_urlsafe_b64encode(
21-
value: Union[str, bytes],
22-
) -> Union[str, bytes]: ...
16+
def string_to_scopes(scopes: Sequence[str] | str) -> list[str]: ...
17+
def padded_urlsafe_b64decode(value: str | bytes) -> bytes: ...
18+
def unpadded_urlsafe_b64encode(value: str | bytes) -> str | bytes: ...
2319
def get_bool_from_env(variable_name: str, default: bool = False) -> bool: ...
2420
def is_python_3() -> bool: ...
2521
def is_logging_enabled(logger: logging.Logger) -> bool: ...
26-
def request_log(
27-
logger: logging.Logger,
28-
method: str,
29-
url: str,
30-
body: Optional[bytes],
31-
headers: Mapping[str, str] | None,
32-
) -> None: ...
22+
def request_log(logger: logging.Logger, method: str, url: str, body: bytes | None, headers: Mapping[str, str] | None) -> None: ...
3323
def response_log(logger: logging.Logger, response: Any) -> None: ...
Lines changed: 24 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,27 @@
1+
from typing import Any, Mapping
2+
3+
from google.auth import _credentials_async, jwt
14
from google.auth.credentials import Signing
2-
from typing import Any, Dict, List, Mapping, Optional, Tuple, Union
3-
import google.auth.jwt as jwt
4-
from google.auth import _credentials_async
55
from google.auth.crypt import Signer as _Signer
66
from google.auth.transport import Request as _Request
77

88
_DEFAULT_TOKEN_LIFETIME_SECS: int
99
_DEFAULT_MAX_CACHE_SIZE: int
10-
_ALGORITHM_TO_VERIFIER_CLASS: Dict[str, type]
10+
_ALGORITHM_TO_VERIFIER_CLASS: dict[str, type]
1111
_CRYPTOGRAPHY_BASED_ALGORITHMS: frozenset[str]
1212

1313
def encode(
14-
signer: _Signer,
15-
payload: Mapping[str, str],
16-
header: Optional[Mapping[str, str]] = None,
17-
key_id: Optional[str] = None,
14+
signer: _Signer, payload: Mapping[str, str], header: Mapping[str, str] | None = None, key_id: str | None = None
1815
) -> bytes: ...
1916
def _decode_jwt_segment(encoded_section: bytes) -> Mapping[str, Any]: ...
20-
def _unverified_decode(
21-
token: Union[str, bytes],
22-
) -> Tuple[Mapping[str, Any], Mapping[str, Any], bytes, bytes]: ...
23-
def decode_header(token: Union[str, bytes]) -> Mapping[str, Any]: ...
24-
def _verify_iat_and_exp(
25-
payload: Mapping[str, str], clock_skew_in_seconds: int = 0
26-
) -> None: ...
17+
def _unverified_decode(token: str | bytes) -> tuple[Mapping[str, Any], Mapping[str, Any], bytes, bytes]: ...
18+
def decode_header(token: str | bytes) -> Mapping[str, Any]: ...
19+
def _verify_iat_and_exp(payload: Mapping[str, str], clock_skew_in_seconds: int = 0) -> None: ...
2720
def decode(
2821
token: str,
29-
certs: Optional[Union[str, bytes, Mapping[str, Union[str, bytes]]]] = None,
22+
certs: str | bytes | Mapping[str, str | bytes] | None = None,
3023
verify: bool = True,
31-
audience: Optional[Union[str, List[str]]] = None,
24+
audience: str | list[str] | None = None,
3225
clock_skew_in_seconds: int = 0,
3326
) -> Mapping[str, Any]: ...
3427

@@ -41,36 +34,26 @@ class Credentials(jwt.Credentials, _credentials_async.Credentials):
4134
issuer: str,
4235
subject: str,
4336
audience: str,
44-
additional_claims: Optional[Mapping[str, str]] = None,
37+
additional_claims: Mapping[str, str] | None = None,
4538
token_lifetime: int = ...,
46-
quota_project_id: Optional[str] = None,
39+
quota_project_id: str | None = None,
4740
) -> None: ...
4841
@classmethod
49-
def _from_signer_and_info(
50-
cls, signer: _Signer, info: Mapping[str, str], **kwargs: Any
51-
) -> "Credentials": ...
42+
def _from_signer_and_info(cls, signer: _Signer, info: Mapping[str, str], **kwargs: Any) -> Credentials: ...
5243
@classmethod
53-
def from_service_account_info(
54-
cls, info: Mapping[str, str], **kwargs: Any
55-
) -> "Credentials": ...
44+
def from_service_account_info(cls, info: Mapping[str, str], **kwargs: Any) -> Credentials: ...
5645
@classmethod
57-
def from_service_account_file(
58-
cls, filename: str, **kwargs: Any
59-
) -> "Credentials": ...
46+
def from_service_account_file(cls, filename: str, **kwargs: Any) -> Credentials: ...
6047
@classmethod
61-
def from_signing_credentials(
62-
cls, credentials: Signing, audience: str, **kwargs: Any
63-
) -> "Credentials": ...
48+
def from_signing_credentials(cls, credentials: Signing, audience: str, **kwargs: Any) -> Credentials: ...
6449
def with_claims(
6550
self,
66-
issuer: Optional[str] = None,
67-
subject: Optional[str] = None,
68-
audience: Optional[str] = None,
69-
additional_claims: Optional[Mapping[str, str]] = None,
70-
) -> "Credentials": ...
71-
def with_quota_project(
72-
self, quota_project_id: Optional[str]
73-
) -> "Credentials": ...
51+
issuer: str | None = None,
52+
subject: str | None = None,
53+
audience: str | None = None,
54+
additional_claims: Mapping[str, str] | None = None,
55+
) -> Credentials: ...
56+
def with_quota_project(self, quota_project_id: str | None) -> Credentials: ...
7457
def refresh(self, request: Any) -> None: ...
7558
def sign_bytes(self, message: bytes) -> bytes: ...
7659
@property
@@ -80,9 +63,7 @@ class Credentials(jwt.Credentials, _credentials_async.Credentials):
8063
@property
8164
def additional_claims(self) -> Mapping[str, str]: ...
8265

83-
class OnDemandCredentials(
84-
jwt.OnDemandCredentials, _credentials_async.Credentials
85-
):
66+
class OnDemandCredentials(jwt.OnDemandCredentials, _credentials_async.Credentials):
8667
"""On-demand JWT credentials.
8768
8869
Like :class:`Credentials`, this class uses a JWT as the bearer token for
@@ -100,10 +81,4 @@ class OnDemandCredentials(
10081
.. _grpc: http://www.grpc.io/
10182
"""
10283

103-
async def before_request(
104-
self,
105-
request: _Request,
106-
method: str,
107-
url: str,
108-
headers: Mapping[str, str],
109-
) -> None: ...
84+
async def before_request(self, request: _Request, method: str, url: str, headers: Mapping[str, str]) -> None: ...

0 commit comments

Comments
 (0)