dycw-utilities 0.151.5__py3-none-any.whl → 0.151.6__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dycw-utilities
3
- Version: 0.151.5
3
+ Version: 0.151.6
4
4
  Author-email: Derek Wan <d.wan@icloud.com>
5
5
  License-File: LICENSE
6
6
  Requires-Python: >=3.12
@@ -1,4 +1,4 @@
1
- utilities/__init__.py,sha256=rDAnptLaac5YF9rfpSwzN4NUEf8bMIfdG3fz1V7gxO0,60
1
+ utilities/__init__.py,sha256=nMhbYUuoPxtD28H8NcP03LIajk-lOLdkrvhyGkeX9UI,60
2
2
  utilities/altair.py,sha256=92E2lCdyHY4Zb-vCw6rEJIsWdKipuu-Tu2ab1ufUfAk,9079
3
3
  utilities/asyncio.py,sha256=2m2a2C-Qgc6OHTTHL332-t66A7xDITt_SORT7a1DJWo,16792
4
4
  utilities/atomicwrites.py,sha256=xcOWenTBRS0oat3kg7Sqe51AohNThMQ2ixPL7QCG8hw,5795
@@ -83,14 +83,14 @@ utilities/tzlocal.py,sha256=KyCXEgCTjqGFx-389JdTuhMRUaT06U1RCMdWoED-qro,728
83
83
  utilities/uuid.py,sha256=32p7DGHGM2Btx6PcBvCZvERSWbpupMXqx6FppPoSoTU,612
84
84
  utilities/version.py,sha256=ufhJMmI6KPs1-3wBI71aj5wCukd3sP_m11usLe88DNA,5117
85
85
  utilities/warnings.py,sha256=un1LvHv70PU-LLv8RxPVmugTzDJkkGXRMZTE2-fTQHw,1771
86
- utilities/whenever.py,sha256=nG9IbFcJTKQJuRxoS35I7ww7pRwKHc1MHxff7vVmJls,44131
86
+ utilities/whenever.py,sha256=iOaUvbc1hjZGtKOvruuOelxZl7Fd203lv77zxMWZ7a0,44773
87
87
  utilities/zipfile.py,sha256=24lQc9ATcJxHXBPc_tBDiJk48pWyRrlxO2fIsFxU0A8,699
88
88
  utilities/zoneinfo.py,sha256=oEH-nL3t4h9uawyZqWDtNtDAl6M-CLpLYGI_nI6DulM,1971
89
89
  utilities/pytest_plugins/__init__.py,sha256=U4S_2y3zgLZVfMenHRaJFBW8yqh2mUBuI291LGQVOJ8,35
90
90
  utilities/pytest_plugins/pytest_randomly.py,sha256=NXzCcGKbpgYouz5yehKb4jmxmi2SexKKpgF4M65bi10,414
91
91
  utilities/pytest_plugins/pytest_regressions.py,sha256=Iwhfv_OJH7UCPZCfoh7ugZ2Xjqjil-BBBsOb8sDwiGI,1471
92
- dycw_utilities-0.151.5.dist-info/METADATA,sha256=tLKFv_elmyBCNcoGEMtAlYBcrLLlXhwKqNFIJ_-c6CA,1696
93
- dycw_utilities-0.151.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
94
- dycw_utilities-0.151.5.dist-info/entry_points.txt,sha256=BOD_SoDxwsfJYOLxhrSXhHP_T7iw-HXI9f2WVkzYxvQ,135
95
- dycw_utilities-0.151.5.dist-info/licenses/LICENSE,sha256=gppZp16M6nSVpBbUBrNL6JuYfvKwZiKgV7XoKKsHzqo,1066
96
- dycw_utilities-0.151.5.dist-info/RECORD,,
92
+ dycw_utilities-0.151.6.dist-info/METADATA,sha256=h0wLqx597yBvnFEeOUoqWv6idBmZ-GJsrxrDuV11aJY,1696
93
+ dycw_utilities-0.151.6.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
94
+ dycw_utilities-0.151.6.dist-info/entry_points.txt,sha256=BOD_SoDxwsfJYOLxhrSXhHP_T7iw-HXI9f2WVkzYxvQ,135
95
+ dycw_utilities-0.151.6.dist-info/licenses/LICENSE,sha256=gppZp16M6nSVpBbUBrNL6JuYfvKwZiKgV7XoKKsHzqo,1066
96
+ dycw_utilities-0.151.6.dist-info/RECORD,,
utilities/__init__.py CHANGED
@@ -1,3 +1,3 @@
1
1
  from __future__ import annotations
2
2
 
3
- __version__ = "0.151.5"
3
+ __version__ = "0.151.6"
utilities/whenever.py CHANGED
@@ -16,6 +16,7 @@ from typing import (
16
16
  overload,
17
17
  override,
18
18
  )
19
+ from zoneinfo import ZoneInfo
19
20
 
20
21
  from whenever import (
21
22
  Date,
@@ -36,8 +37,6 @@ from utilities.tzlocal import LOCAL_TIME_ZONE, LOCAL_TIME_ZONE_NAME
36
37
  from utilities.zoneinfo import UTC, get_time_zone_name
37
38
 
38
39
  if TYPE_CHECKING:
39
- from zoneinfo import ZoneInfo
40
-
41
40
  from utilities.types import (
42
41
  DateOrDateTimeDelta,
43
42
  DateTimeRoundMode,
@@ -1418,22 +1417,40 @@ class _ToYearsTimeError(ToYearsError):
1418
1417
 
1419
1418
 
1420
1419
  @overload
1421
- def to_zoned_date_time(*, date_time: MaybeCallableZonedDateTime) -> ZonedDateTime: ...
1420
+ def to_zoned_date_time(
1421
+ *, date_time: MaybeCallableZonedDateTime | dt.datetime
1422
+ ) -> ZonedDateTime: ...
1422
1423
  @overload
1423
1424
  def to_zoned_date_time(*, date_time: None) -> None: ...
1424
1425
  @overload
1425
1426
  def to_zoned_date_time(*, date_time: Sentinel) -> Sentinel: ...
1426
1427
  def to_zoned_date_time(
1427
- *, date_time: MaybeCallableZonedDateTime | None | Sentinel = sentinel
1428
+ *, date_time: MaybeCallableZonedDateTime | dt.datetime | None | Sentinel = sentinel
1428
1429
  ) -> ZonedDateTime | None | Sentinel:
1429
1430
  """Resolve into a zoned date_time."""
1430
1431
  match date_time:
1431
1432
  case ZonedDateTime() | None | Sentinel():
1432
1433
  return date_time
1434
+ case dt.datetime():
1435
+ if isinstance(date_time.tzinfo, ZoneInfo):
1436
+ return ZonedDateTime.from_py_datetime(date_time)
1437
+ if date_time.tzinfo is dt.UTC:
1438
+ return ZonedDateTime.from_py_datetime(date_time.astimezone(UTC))
1439
+ raise ToZonedDateTimeError(date_time=date_time)
1433
1440
  case Callable() as func:
1434
1441
  return to_zoned_date_time(date_time=func())
1435
1442
  case _ as never:
1436
1443
  assert_never(never)
1444
+ return None
1445
+
1446
+
1447
+ @dataclass(kw_only=True, slots=True)
1448
+ class ToZonedDateTimeError(Exception):
1449
+ date_time: dt.datetime
1450
+
1451
+ @override
1452
+ def __str__(self) -> str:
1453
+ return f"Expected date-time to have a `ZoneInfo` or `dt.UTC` as its timezone; got {self.date_time.tzinfo}"
1437
1454
 
1438
1455
 
1439
1456
  ##