Skip to content

Commit 7dbe178

Browse files
committed
chore: upgrade whenever for py3.14 compat
Signed-off-by: Fatih Acar <[email protected]>
1 parent d21c500 commit 7dbe178

File tree

5 files changed

+91
-75
lines changed

5 files changed

+91
-75
lines changed

infrahub_sdk/timestamp.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from typing import Literal, TypedDict
77

88
from typing_extensions import NotRequired
9-
from whenever import Date, Instant, LocalDateTime, OffsetDateTime, Time, ZonedDateTime
9+
from whenever import Date, Instant, OffsetDateTime, PlainDateTime, Time, ZonedDateTime
1010

1111
from .exceptions import TimestampFormatError
1212

@@ -51,30 +51,30 @@ def obj(self) -> ZonedDateTime:
5151
@classmethod
5252
def _parse_string(cls, value: str) -> ZonedDateTime:
5353
try:
54-
return ZonedDateTime.parse_common_iso(value)
54+
return ZonedDateTime.parse_iso(value)
5555
except ValueError:
5656
pass
5757

5858
try:
59-
instant_date = Instant.parse_common_iso(value)
59+
instant_date = Instant.parse_iso(value)
6060
return instant_date.to_tz("UTC")
6161
except ValueError:
6262
pass
6363

6464
try:
65-
local_date_time = LocalDateTime.parse_common_iso(value)
66-
return local_date_time.assume_utc().to_tz("UTC")
65+
plain_date_time = PlainDateTime.parse_iso(value)
66+
return plain_date_time.assume_utc().to_tz("UTC")
6767
except ValueError:
6868
pass
6969

7070
try:
71-
offset_date_time = OffsetDateTime.parse_common_iso(value)
71+
offset_date_time = OffsetDateTime.parse_iso(value)
7272
return offset_date_time.to_tz("UTC")
7373
except ValueError:
7474
pass
7575

7676
try:
77-
date = Date.parse_common_iso(value)
77+
date = Date.parse_iso(value)
7878
local_date = date.at(Time(12, 00))
7979
return local_date.assume_tz("UTC", disambiguate="compatible")
8080
except ValueError:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ dependencies = [
2424
"httpx>=0.20",
2525
"ujson>=5",
2626
"dulwich>=0.21.4",
27-
"whenever>=0.7.2,<0.8.0",
27+
"whenever>=0.9.3,<0.10.0",
2828
"netutils>=1.0.0",
2929
"tomli>=1.1.0; python_version<'3.11'",
3030
]

tests/unit/sdk/test_timestamp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def test_init_timestamp() -> None:
3030
def test_parse_string() -> None:
3131
REF = "2022-01-01T10:00:00.000000Z"
3232

33-
assert Timestamp._parse_string(REF).instant() == Instant.parse_common_iso(REF)
33+
assert Timestamp._parse_string(REF).to_instant() == Instant.parse_iso(REF)
3434
assert Timestamp._parse_string("5m")
3535
assert Timestamp._parse_string("10min")
3636
assert Timestamp._parse_string("2h")

tests/unit/sdk/test_utils.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -217,19 +217,19 @@ def test_write_to_file() -> None:
217217

218218

219219
def test_calculate_time_diff() -> None:
220-
time1 = Instant.now().subtract(seconds=98).format_common_iso()
220+
time1 = Instant.now().subtract(seconds=98).format_iso()
221221
assert calculate_time_diff(time1) == "1m and 38s ago"
222222

223-
time2 = Instant.now().subtract(hours=1, minutes=12, seconds=34).format_common_iso()
223+
time2 = Instant.now().subtract(hours=1, minutes=12, seconds=34).format_iso()
224224
assert calculate_time_diff(time2) == "1h 12m and 34s ago"
225225

226-
time3 = Instant.now().format_common_iso()
226+
time3 = Instant.now().format_iso()
227227
assert calculate_time_diff(time3) == "now"
228228

229-
time4 = Instant.now().subtract(seconds=23).format_common_iso()
229+
time4 = Instant.now().subtract(seconds=23).format_iso()
230230
assert calculate_time_diff(time4) == "23s ago"
231231

232-
time5 = Instant.now().subtract(hours=77, minutes=12, seconds=34).format_common_iso()
232+
time5 = Instant.now().subtract(hours=77, minutes=12, seconds=34).format_iso()
233233
assert calculate_time_diff(time5) == "3d and 5h ago"
234234

235235

0 commit comments

Comments
 (0)