Skip to content

Commit 2a4a720

Browse files
committed
removed unnecessary package dependencies
1 parent 67357fc commit 2a4a720

File tree

2 files changed

+3
-35
lines changed

2 files changed

+3
-35
lines changed

ellar_jwt/util.py

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,5 @@
1-
import sys
21
from calendar import timegm
3-
from datetime import datetime, tzinfo
4-
5-
from dateutil import tz as dateutil_tz
6-
from pytz import utc
7-
8-
if sys.version_info >= (3, 9): # pragma: no cover
9-
from zoneinfo import ZoneInfo
10-
else: # pragma: no cover
11-
from backports.zoneinfo import ZoneInfo
12-
13-
14-
def _can_detect_ambiguous(tz: tzinfo) -> bool:
15-
"""Helper function to determine if a timezone can detect ambiguous times using dateutil."""
16-
17-
return isinstance(tz, ZoneInfo) or hasattr(tz, "is_ambiguous")
18-
19-
20-
def _is_ambigious(dt: datetime, tz: tzinfo) -> bool:
21-
"""Helper function to determine if a timezone is ambiguous using python's dateutil module.
22-
23-
Returns False if the timezone cannot detect ambiguity, or if there is no ambiguity, otherwise True.
24-
25-
In order to detect ambiguous datetimes, the timezone must be built using ZoneInfo, or have an is_ambiguous
26-
method. Previously, pytz timezones would throw an AmbiguousTimeError if the localized dt was ambiguous,
27-
but now we need to specifically check for ambiguity with dateutil, as pytz is deprecated.
28-
"""
29-
30-
return _can_detect_ambiguous(tz) and dateutil_tz.datetime_ambiguous(dt)
2+
from datetime import datetime, timezone, tzinfo
313

324

335
def is_naive(dt: datetime) -> bool:
@@ -39,14 +11,12 @@ def make_aware(dt: datetime, tz: tzinfo) -> datetime:
3911
"""Set timezone for a :class:`~datetime.datetime` object."""
4012

4113
dt = dt.replace(tzinfo=tz)
42-
if _is_ambigious(dt, tz): # pragma: no cover
43-
dt = min(dt.replace(fold=0), dt.replace(fold=1))
4414
return dt
4515

4616

4717
def make_utc(dt: datetime) -> datetime:
4818
if is_naive(dt):
49-
dt = make_aware(dt, tz=utc)
19+
dt = make_aware(dt, tz=timezone.utc)
5020
return dt
5121

5222

pyproject.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@ classifiers = [
4242
dependencies = [
4343
"ellar >= 0.4.2",
4444
"pyjwt>=1.7.1,<3",
45-
"pyjwt[crypto]",
46-
"python-dateutil",
47-
"pytz",
45+
"pyjwt[crypto]"
4846
]
4947

5048
crypto = [

0 commit comments

Comments
 (0)