Skip to content

fix(types): add full type annotations to _requests_base for Mypy strict mode (#1508) #1719

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions google/auth/transport/_requests_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
# since it is currently unused.

import abc
from typing import Any, Dict, Optional, Union


_DEFAULT_TIMEOUT = 120 # in second
_DEFAULT_TIMEOUT: Union[int, float] = 120 # in seconds


class _BaseAuthorizedSession(metaclass=abc.ABCMeta):
Expand All @@ -32,22 +33,24 @@ class _BaseAuthorizedSession(metaclass=abc.ABCMeta):
add to the request.
"""

def __init__(self, credentials):
def __init__(self, credentials: Any) -> None:
self.credentials = credentials

@abc.abstractmethod
def request(
self,
method,
url,
data=None,
headers=None,
max_allowed_time=None,
timeout=_DEFAULT_TIMEOUT,
**kwargs
):
method: str,
url: str,
data: Optional[bytes] = None,
headers: Optional[Dict[str, str]] = None,
max_allowed_time: Optional[Union[int, float]] = None,
timeout: Union[int, float] = _DEFAULT_TIMEOUT,
**kwargs: Any,
) -> Any:
"""Abstract request method to be implemented by subclasses."""
raise NotImplementedError("Request must be implemented")

@abc.abstractmethod
def close(self):
def close(self) -> None:
"""Abstract close method to be implemented by subclasses."""
raise NotImplementedError("Close must be implemented")