Skip to content

Commit

Permalink
refactor: Use datetime.timezone.utc instead of pytz.UTC where pos…
Browse files Browse the repository at this point in the history
…sible
  • Loading branch information
edgarrmondragon committed Jan 18, 2024
1 parent 02f6288 commit 4689a7b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Local Poetry configuration file

poetry.toml

# CI

_changelog_fragment.md
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ fail_under = 82
[tool.mypy]
exclude = "tests"
files = "singer_sdk"
python_version = "3.8"
warn_redundant_casts = true
warn_return_any = true
warn_unused_configs = true
Expand Down
8 changes: 3 additions & 5 deletions singer_sdk/_singerlib/utils.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
from __future__ import annotations

import sys
from datetime import datetime, timedelta

import pytz
from datetime import datetime, timedelta, timezone

if sys.version_info < (3, 11):
from backports.datetime_fromisoformat import MonkeyPatch
Expand Down Expand Up @@ -33,9 +31,9 @@ def strptime_to_utc(dtimestr: str) -> datetime:
"""
d_object: datetime = datetime.fromisoformat(dtimestr)
if d_object.tzinfo is None:
return d_object.replace(tzinfo=pytz.UTC)
return d_object.replace(tzinfo=timezone.utc)

return d_object.astimezone(tz=pytz.UTC)
return d_object.astimezone(tz=timezone.utc)


def strftime(dtime: datetime, format_str: str = DATETIME_FMT) -> str:
Expand Down

0 comments on commit 4689a7b

Please sign in to comment.