Skip to content

Commit

Permalink
refactor: Limit internal usage of pendulum
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon committed Jan 9, 2024
1 parent 586fc94 commit ebdfe3a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,9 @@ typing = "t"
fixture-parentheses = false
parametrize-names-type = "csv"

[tool.ruff.lint.flake8-tidy-imports.banned-api]
"pendulum".msg = "BAN002: pendulum is banned"

[tool.ruff.lint.isort]
known-first-party = ["singer_sdk", "samples", "tests"]
required-imports = ["from __future__ import annotations"]
Expand Down
5 changes: 2 additions & 3 deletions singer_sdk/authenticators.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@
from singer_sdk.helpers._util import utc_now

if t.TYPE_CHECKING:
import datetime
import logging

from pendulum import DateTime

from singer_sdk.streams.rest import RESTStream


Expand Down Expand Up @@ -380,7 +379,7 @@ def __init__(
# Initialize internal tracking attributes
self.access_token: str | None = None
self.refresh_token: str | None = None
self.last_refreshed: DateTime | None = None
self.last_refreshed: datetime.datetime | None = None
self.expires_in: int | None = None

@property
Expand Down
7 changes: 3 additions & 4 deletions singer_sdk/helpers/_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

from __future__ import annotations

import datetime
import json
import typing as t
from pathlib import Path, PurePath

import pendulum


def read_json_file(path: PurePath | str) -> dict[str, t.Any]:
"""Read json file, throwing an error if missing."""
Expand All @@ -25,6 +24,6 @@ def read_json_file(path: PurePath | str) -> dict[str, t.Any]:
return t.cast(dict, json.loads(Path(path).read_text()))


def utc_now() -> pendulum.DateTime:
def utc_now() -> datetime.datetime:
"""Return current time in UTC."""
return pendulum.now(tz="UTC")
return datetime.datetime.now(datetime.timezone.utc)
4 changes: 2 additions & 2 deletions singer_sdk/sinks/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
from textwrap import dedent

import sqlalchemy as sa
from pendulum import now
from sqlalchemy.sql.expression import bindparam

from singer_sdk.connectors import SQLConnector
from singer_sdk.exceptions import ConformedNameClashException
from singer_sdk.helpers._conformers import replace_leading_digit
from singer_sdk.helpers._util import utc_now
from singer_sdk.sinks.batch import BatchSink

if t.TYPE_CHECKING:
Expand Down Expand Up @@ -366,7 +366,7 @@ def activate_version(self, new_version: int) -> None:
if not self.connector.table_exists(self.full_table_name):
return

deleted_at = now()
deleted_at = utc_now()

if not self.connector.column_exists(
full_table_name=self.full_table_name,
Expand Down

0 comments on commit ebdfe3a

Please sign in to comment.