Skip to content

Commit

Permalink
WIP: Use .context attribue form sdk#2529 (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon authored Jul 12, 2024
1 parent 4171a3c commit 169a7d0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ dynamic = [
"version",
]
dependencies = [
"singer-sdk~=0.38.0",
"singer-sdk~=0.39.0a1",
]
optional-dependencies.dev = [
"tap-nasa[testing,typing]",
]
optional-dependencies.testing = [
"deptry>=0.12",
"pytest>=8",
"singer-sdk[testing]",
"singer-sdk[testing]~=0.39.0a1",
]
optional-dependencies.typing = [
"mypy",
Expand Down
14 changes: 7 additions & 7 deletions tap_nasa/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
from singer_sdk.authenticators import APIKeyAuthenticator
from singer_sdk.pagination import BaseAPIPaginator

if t.TYPE_CHECKING:
from singer_sdk.helpers import types

DATE_FORMAT = "%Y-%m-%d"


Expand Down Expand Up @@ -39,7 +42,7 @@ def increase(self) -> DateRange:
self.max_date,
)

def valid(self) -> bool:
def is_valid(self) -> bool:
"""Check if the date range is not past the max date.
Returns:
Expand Down Expand Up @@ -70,10 +73,7 @@ def get_next(self, response) -> DateRange | None: # type: ignore[no-untyped-def
"""
new = self.current_value.increase()

if new.valid():
return new

return None
return new if new.is_valid() else None


class NASAStream(RESTStream[DateRange]):
Expand Down Expand Up @@ -156,7 +156,7 @@ def http_headers(self) -> dict[str, str]:

def get_new_paginator(self) -> DateRangePaginator:
"""Get a new paginator."""
start_dt = self.get_starting_timestamp(context=None)
start_dt = self.get_starting_timestamp(context=self.context)

if start_dt is None:
msg = "A start date is required"
Expand All @@ -174,7 +174,7 @@ def get_new_paginator(self) -> DateRangePaginator:

def get_url_params(
self,
context: dict[str, t.Any] | None,
context: types.Context[str, t.Any] | None,
next_page_token: DateRange | None,
) -> dict[str, t.Any] | str:
"""Get URL query parameters.
Expand Down

0 comments on commit 169a7d0

Please sign in to comment.