Skip to content

Commit faa2739

Browse files
committed
Add type stubs for google-auth-library-python
1 parent 72b7368 commit faa2739

Some content is hidden

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

78 files changed

+2710
-0
lines changed

stubs/google/auth/__init__.pyi

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from google.auth._default import default as default, load_credentials_from_dict as load_credentials_from_dict, load_credentials_from_file as load_credentials_from_file
2+
3+
__all__ = ['default', 'load_credentials_from_file', 'load_credentials_from_dict']
4+
5+
class Python37DeprecationWarning(DeprecationWarning): ...
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from typing import Any, Optional
2+
3+
CRYPTOGRAPHY_NOT_FOUND_ERROR: str
4+
5+
def get_agent_identity_certificate_path() -> Optional[str]: ...
6+
def get_and_parse_agent_identity_certificate() -> Optional[Any]: ...
7+
def parse_certificate(cert_bytes: bytes) -> Any: ...
8+
def calculate_certificate_fingerprint(cert: Any) -> str: ...
9+
def should_request_bound_token(cert: Any) -> bool: ...
10+
def get_cached_cert_fingerprint(cached_cert: Optional[bytes]) -> str: ...

stubs/google/auth/_cache.pyi

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from typing import Hashable, TypeVar
2+
3+
_Key = TypeVar("_Key", bound=Hashable)
4+
_Value = TypeVar("_Value")
5+
6+
class LRUCache(dict[_Key, _Value]):
7+
maxsize: int
8+
9+
def __init__(self, maxsize: int) -> None: ...
10+
def clear(self) -> None: ...
11+
def __getitem__(self, key: _Key) -> _Value: ...
12+
def __setitem__(self, key: _Key, value: _Value) -> None: ...
13+
def __delitem__(self, key: _Key) -> None: ...
14+
def popitem(self) -> tuple[_Key, _Value]: ...
15+
def _update(self, key: _Key) -> None: ...

stubs/google/auth/_cloud_sdk.pyi

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from typing import Optional
2+
3+
CLOUD_SDK_CLIENT_ID: str
4+
5+
def get_config_path() -> str: ...
6+
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: ...

stubs/google/auth/_constants.pyi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
_SERVICE_ACCOUNT_TRUST_BOUNDARY_LOOKUP_ENDPOINT: str
2+
_WORKFORCE_POOL_TRUST_BOUNDARY_LOOKUP_ENDPOINT: str
3+
_WORKLOAD_IDENTITY_POOL_TRUST_BOUNDARY_LOOKUP_ENDPOINT: str
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import abc
2+
from typing import Mapping, Sequence
3+
4+
from google.auth import credentials
5+
from google.auth.transport import Request as _Request
6+
7+
class Credentials(credentials.Credentials, metaclass=abc.ABCMeta):
8+
async def before_request(
9+
self, request: _Request, method: str, url: str, headers: Mapping[str, str]
10+
) -> None: ...
11+
12+
class CredentialsWithQuotaProject(
13+
credentials.CredentialsWithQuotaProject, metaclass=abc.ABCMeta
14+
): ...
15+
class AnonymousCredentials(credentials.AnonymousCredentials, Credentials): ...
16+
class ReadOnlyScoped(credentials.ReadOnlyScoped, metaclass=abc.ABCMeta): ...
17+
class Scoped(credentials.Scoped, metaclass=abc.ABCMeta): ...
18+
19+
def with_scopes_if_required(
20+
credentials: "Credentials", scopes: Sequence[str]
21+
) -> "Credentials": ...
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import abc
2+
3+
from _typeshed import Incomplete
4+
from google.auth.transport import Request as _TransportRequest
5+
6+
class _BaseCredentials(metaclass=abc.ABCMeta):
7+
token: Incomplete
8+
9+
def __init__(self) -> None: ...
10+
@abc.abstractmethod
11+
def refresh(self, request: _TransportRequest) -> None: ...

stubs/google/auth/_default.pyi

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from typing import TYPE_CHECKING, Any, Mapping, Optional, Sequence, Tuple
2+
3+
from google.auth.credentials import Credentials as Credentials
4+
from google.auth.transport import Request as Request
5+
6+
if TYPE_CHECKING:
7+
from google.auth.api_key import Credentials as _ApiKeyCredentials
8+
9+
def load_credentials_from_file(
10+
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]]: ...
16+
def load_credentials_from_dict(
17+
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": ...
24+
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]]: ...
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from typing import Optional, Sequence, Tuple
2+
3+
from google.auth.credentials import Credentials as Credentials
4+
from google.auth.transport import Request as _Request
5+
6+
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]]: ...
11+
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]]: ...
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
class _BaseExponentialBackoff:
2+
def __init__(
3+
self,
4+
total_attempts: int = 3,
5+
initial_wait_seconds: float = 1.0,
6+
randomization_factor: float = 0.1,
7+
multiplier: float = 2.0,
8+
) -> None: ...
9+
@property
10+
def total_attempts(self) -> int: ...
11+
@property
12+
def backoff_count(self) -> int: ...
13+
14+
class ExponentialBackoff(_BaseExponentialBackoff):
15+
def __init__(self, *args: object, **kwargs: object) -> None: ...
16+
def __iter__(self) -> "ExponentialBackoff": ...
17+
def __next__(self) -> int: ...
18+
19+
class AsyncExponentialBackoff(_BaseExponentialBackoff):
20+
def __init__(self, *args: object, **kwargs: object) -> None: ...
21+
def __aiter__(self) -> "AsyncExponentialBackoff": ...
22+
async def __anext__(self) -> int: ...

0 commit comments

Comments
 (0)