From 4855fcb81bb1129de436587f8fc965570e1d7cdb Mon Sep 17 00:00:00 2001 From: Kevin K Date: Mon, 2 May 2022 16:05:17 -0600 Subject: [PATCH 1/2] typed dunder init func, imported dependencies --- adafruit_oauth2.py | 19 ++++++++++++------- requirements.txt | 3 ++- setup.py | 1 + 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/adafruit_oauth2.py b/adafruit_oauth2.py index 6f57cb8..52c48a3 100644 --- a/adafruit_oauth2.py +++ b/adafruit_oauth2.py @@ -22,6 +22,11 @@ https://github.com/adafruit/circuitpython/releases """ +try: + from typing import Optional + import adafruit_requests +except ImportError: + pass # imports import time @@ -52,13 +57,13 @@ class OAuth2: # pylint: disable=too-many-arguments, too-many-instance-attribute def __init__( self, - requests, - client_id, - client_secret, - scopes, - access_token=None, - refresh_token=None, - ): + requests: adafruit_requests.Session, + client_id: str, + client_secret: str, + scopes: list, + access_token: Optional[str] = None, + refresh_token: Optional[str] = None, + ) -> None: self._requests = requests self._client_id = client_id self._client_secret = client_secret diff --git a/requirements.txt b/requirements.txt index d67bac0..e4140c8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,4 +4,5 @@ # SPDX-License-Identifier: MIT Adafruit-Blinka -adafruit-circuitpython-requests +adafruit-circuitpython-requests, +adafruit-requests diff --git a/setup.py b/setup.py index 249eeb0..f39debc 100644 --- a/setup.py +++ b/setup.py @@ -37,6 +37,7 @@ install_requires=[ "Adafruit-Blinka", "adafruit-circuitpython-requests", + "adafruit-requests", ], # Choose your license license="MIT", From 20436845e0fca6898b5569e57334515af43bc7f3 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 16 May 2022 11:24:39 -0500 Subject: [PATCH 2/2] remove extra requests requirement. update docstring for requests session --- adafruit_oauth2.py | 6 +++--- requirements.txt | 3 +-- setup.py | 1 - 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/adafruit_oauth2.py b/adafruit_oauth2.py index 52c48a3..6a8dad9 100644 --- a/adafruit_oauth2.py +++ b/adafruit_oauth2.py @@ -23,7 +23,7 @@ """ try: - from typing import Optional + from typing import Optional, List import adafruit_requests except ImportError: pass @@ -46,7 +46,7 @@ class OAuth2: # pylint: disable=too-many-arguments, too-many-instance-attribute """Implements OAuth2.0 authorization to access Google APIs via the OAuth 2.0 limited-input device application flow. https://developers.google.com/identity/protocols/oauth2/limited-input-device - :param requests: An adafruit_requests object. + :param adafruit_requests.Session requests: An adafruit_requests object. :param str client_id: The client ID for your application. :param str client_secret: The client secret obtained from the API Console. :param list scopes: Scopes that identify the resources used by the application. @@ -60,7 +60,7 @@ def __init__( requests: adafruit_requests.Session, client_id: str, client_secret: str, - scopes: list, + scopes: List[str], access_token: Optional[str] = None, refresh_token: Optional[str] = None, ) -> None: diff --git a/requirements.txt b/requirements.txt index e4140c8..d67bac0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,5 +4,4 @@ # SPDX-License-Identifier: MIT Adafruit-Blinka -adafruit-circuitpython-requests, -adafruit-requests +adafruit-circuitpython-requests diff --git a/setup.py b/setup.py index f39debc..249eeb0 100644 --- a/setup.py +++ b/setup.py @@ -37,7 +37,6 @@ install_requires=[ "Adafruit-Blinka", "adafruit-circuitpython-requests", - "adafruit-requests", ], # Choose your license license="MIT",