From cec080f78dcf1160db97264bb1d477c71f395ab5 Mon Sep 17 00:00:00 2001 From: Josh lloyd Date: Wed, 4 Sep 2024 08:48:17 -0600 Subject: [PATCH] fixed linting errors, rev 1.4.0 --- pyproject.toml | 2 +- tap_rest_api_msdk/auth.py | 4 ++-- tap_rest_api_msdk/tap.py | 11 +++++++---- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index a690720..b6d32e5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "tap-rest-api-msdk" -version = "1.3.11" +version = "1.4.0" description = "`tap-rest-api-msdk` is a Singer tap for REST APIs, built with the Meltano SDK for Singer Taps." authors = ["Josh Lloyd", "Fred Reimer"] keywords = [ diff --git a/tap_rest_api_msdk/auth.py b/tap_rest_api_msdk/auth.py index d2304ac..2530e79 100644 --- a/tap_rest_api_msdk/auth.py +++ b/tap_rest_api_msdk/auth.py @@ -116,9 +116,9 @@ def get_aws_session_client(self): class ConfigurableOAuthAuthenticator(OAuthAuthenticator): """Configurable OAuth Authenticator.""" - + def get_initial_oauth_token(self): - """Gets a oauth token for the tap schema discovery. + """Get oauth token for the tap schema discovery. Requests an oauth token and sets the auth headers. """ diff --git a/tap_rest_api_msdk/tap.py b/tap_rest_api_msdk/tap.py index 2524d17..7534155 100644 --- a/tap_rest_api_msdk/tap.py +++ b/tap_rest_api_msdk/tap.py @@ -2,14 +2,15 @@ import copy import json -from typing import Any, List +from typing import Any, List, Optional import requests from genson import SchemaBuilder from singer_sdk import Tap from singer_sdk import typing as th +from singer_sdk.authenticators import APIAuthenticatorBase from singer_sdk.helpers.jsonpath import extract_jsonpath -from tap_rest_api_msdk.auth import get_authenticator +from tap_rest_api_msdk.auth import ConfigurableOAuthAuthenticator, get_authenticator from tap_rest_api_msdk.streams import DynamicStream from tap_rest_api_msdk.utils import flatten_json @@ -24,7 +25,7 @@ class TapRestApiMsdk(Tap): # Used to cache the Authenticator to prevent over hitting the Authentication # end-point for each stream. - _authenticator = None + _authenticator: Optional[APIAuthenticatorBase] = None common_properties = th.PropertiesList( th.Property( @@ -583,7 +584,9 @@ def get_schema( get_authenticator(self) # Get an initial oauth token if an oauth method - if auth_method == 'oauth': + if auth_method == "oauth" and isinstance( + self._authenticator, ConfigurableOAuthAuthenticator + ): self._authenticator.get_initial_oauth_token() headers.update(getattr(self._authenticator, "auth_headers", {}))