Skip to content

Commit c2673aa

Browse files
authored
Replace pytz with standard library datetime timezones. (PP-3821) (#893)
## Description - Replaces `pytz` with standard library datetime timezones. - Removes `pytz` from project dependencies. ## Motivation and Context `pytz` use is discouraged for Python 3.9 and later. Our minimum supported version is 3.12. And nice to have one less dependency to deal with. [Jira PP-3821] ## How Has This Been Tested? - No tests were changed. - All tests continue to pass locally. - CI tests. ## Checklist - N/A - I have updated the documentation accordingly. - [x] All new and existing tests passed.
1 parent a7c41fa commit c2673aa

File tree

4 files changed

+4
-8
lines changed

4 files changed

+4
-8
lines changed

poetry.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ Pillow = "*"
4040
pycryptodome = "*"
4141
PyJWT = "*"
4242
python = ">=3.12,<4"
43-
pytz = "^2026.1"
4443
requests = "2.32.5"
4544
SQLAlchemy = "^1.4"
4645
uszipcode = "==1.0.1"
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import datetime
22

3-
import pytz
4-
53

64
def utc_now() -> datetime.datetime:
75
"""Get the current time in UTC.
86
97
:return: datetime object
108
"""
11-
return datetime.datetime.now(tz=pytz.UTC)
9+
return datetime.datetime.now(tz=datetime.UTC)

src/palace/registry/util/short_client_token.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import datetime
33
import logging
44

5-
import pytz
65
from jwt.algorithms import HMACAlgorithm
76

87
from palace.registry.util.datetime_helpers import utc_now
@@ -43,12 +42,12 @@ def adobe_base64_decode(cls, to_decode):
4342
return base64.decodebytes(to_decode)
4443

4544
JWT_EPOCH = datetime.datetime(
46-
1970, 1, 1, tzinfo=pytz.UTC
45+
1970, 1, 1, tzinfo=datetime.UTC
4746
) # The JWT spec takes January 1 1970 as the epoch.
4847

4948
# For the sake of shortening tokens, the Short Client Token spec takes January 1 2017 as the epoch,
5049
# and measures time in minutes rather than seconds.
51-
SCT_EPOCH = datetime.datetime(2017, 1, 1, tzinfo=pytz.UTC)
50+
SCT_EPOCH = datetime.datetime(2017, 1, 1, tzinfo=datetime.UTC)
5251

5352
@classmethod
5453
def sct_numericdate(cls, d):

0 commit comments

Comments
 (0)