dycw-utilities 0.166.1__py3-none-any.whl → 0.166.2__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.166.1
3
+ Version: 0.166.2
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=pk8s8uyCf9TfamkXymCVi1C6C_xH9yc5UV3b1hbP1Nk,60
1
+ utilities/__init__.py,sha256=NNNZPLvpz8NHxcszE2dbVPYUi7cTPpL0VlUzD3PFpEU,60
2
2
  utilities/aeventkit.py,sha256=ddoleSwW9zdc2tjX5Ge0pMKtYwV_JMxhHYOxnWX2AGM,12609
3
3
  utilities/altair.py,sha256=92E2lCdyHY4Zb-vCw6rEJIsWdKipuu-Tu2ab1ufUfAk,9079
4
4
  utilities/asyncio.py,sha256=PUedzQ5deqlSECQ33sam9cRzI9TnygHz3FdOqWJWPTM,15288
@@ -82,14 +82,14 @@ utilities/tzlocal.py,sha256=KyCXEgCTjqGFx-389JdTuhMRUaT06U1RCMdWoED-qro,728
82
82
  utilities/uuid.py,sha256=nQZs6tFX4mqtc2Ku3KqjloYCqwpTKeTj8eKwQwh3FQI,1572
83
83
  utilities/version.py,sha256=ipBj5-WYY_nelp2uwFlApfWWCzTLzPwpovUi9x_OBMs,5085
84
84
  utilities/warnings.py,sha256=un1LvHv70PU-LLv8RxPVmugTzDJkkGXRMZTE2-fTQHw,1771
85
- utilities/whenever.py,sha256=8jQZkE3_8E4A10oQM-OYIJpWtvBBtYTf-WIv3cVxL9w,57555
85
+ utilities/whenever.py,sha256=aeeas2SsA6Uq__tmm2kiYQZaOE_TklPsWCD_JGS3czs,57916
86
86
  utilities/zipfile.py,sha256=24lQc9ATcJxHXBPc_tBDiJk48pWyRrlxO2fIsFxU0A8,699
87
87
  utilities/zoneinfo.py,sha256=tdIScrTB2-B-LH0ukb1HUXKooLknOfJNwHk10MuMYvA,3619
88
88
  utilities/pytest_plugins/__init__.py,sha256=U4S_2y3zgLZVfMenHRaJFBW8yqh2mUBuI291LGQVOJ8,35
89
89
  utilities/pytest_plugins/pytest_randomly.py,sha256=B1qYVlExGOxTywq2r1SMi5o7btHLk2PNdY_b1p98dkE,409
90
90
  utilities/pytest_plugins/pytest_regressions.py,sha256=9v8kAXDM2ycIXJBimoiF4EgrwbUvxTycFWJiGR_GHhM,1466
91
- dycw_utilities-0.166.1.dist-info/METADATA,sha256=tFhmfKrHbWlljJMUoGWMcLeXSJiVMMXbAAqlqwE6rTQ,1696
92
- dycw_utilities-0.166.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
93
- dycw_utilities-0.166.1.dist-info/entry_points.txt,sha256=BOD_SoDxwsfJYOLxhrSXhHP_T7iw-HXI9f2WVkzYxvQ,135
94
- dycw_utilities-0.166.1.dist-info/licenses/LICENSE,sha256=gppZp16M6nSVpBbUBrNL6JuYfvKwZiKgV7XoKKsHzqo,1066
95
- dycw_utilities-0.166.1.dist-info/RECORD,,
91
+ dycw_utilities-0.166.2.dist-info/METADATA,sha256=eQxPlntL_GXTG8DmFDjXmdVY4Rpyl7euahHf_yW3Rk8,1696
92
+ dycw_utilities-0.166.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
93
+ dycw_utilities-0.166.2.dist-info/entry_points.txt,sha256=BOD_SoDxwsfJYOLxhrSXhHP_T7iw-HXI9f2WVkzYxvQ,135
94
+ dycw_utilities-0.166.2.dist-info/licenses/LICENSE,sha256=gppZp16M6nSVpBbUBrNL6JuYfvKwZiKgV7XoKKsHzqo,1066
95
+ dycw_utilities-0.166.2.dist-info/RECORD,,
utilities/__init__.py CHANGED
@@ -1,3 +1,3 @@
1
1
  from __future__ import annotations
2
2
 
3
- __version__ = "0.166.1"
3
+ __version__ = "0.166.2"
utilities/whenever.py CHANGED
@@ -13,7 +13,6 @@ from typing import (
13
13
  Self,
14
14
  SupportsFloat,
15
15
  TypedDict,
16
- TypeVar,
17
16
  assert_never,
18
17
  cast,
19
18
  overload,
@@ -146,9 +145,6 @@ def sub_year_month(x: YearMonth, /, *, years: int = 0, months: int = 0) -> YearM
146
145
  ##
147
146
 
148
147
 
149
- _TDate_co = TypeVar("_TDate_co", bound=Date | dt.date, covariant=True)
150
-
151
-
152
148
  @dataclass(repr=False, order=True, unsafe_hash=True, kw_only=False)
153
149
  class DatePeriod:
154
150
  """A period of dates."""
@@ -210,7 +206,7 @@ class DatePeriod:
210
206
  return f"{fc(start)}-{fc(end)}"
211
207
 
212
208
  @classmethod
213
- def from_dict(cls, mapping: PeriodDict[_TDate_co], /) -> Self:
209
+ def from_dict(cls, mapping: PeriodDict[Date] | PeriodDict[dt.date], /) -> Self:
214
210
  """Convert the dictionary to a period."""
215
211
  match mapping["start"]:
216
212
  case Date() as start:
@@ -238,6 +234,10 @@ class DatePeriod:
238
234
  """Convert the period to a dictionary."""
239
235
  return PeriodDict(start=self.start, end=self.end)
240
236
 
237
+ def to_py_dict(self) -> PeriodDict[dt.date]:
238
+ """Convert the period to a dictionary."""
239
+ return PeriodDict(start=self.start.py_date(), end=self.end.py_date())
240
+
241
241
 
242
242
  @dataclass(kw_only=True, slots=True)
243
243
  class DatePeriodError(Exception):
@@ -788,9 +788,6 @@ class _RoundDateOrDateTimeDateTimeIntraDayWithWeekdayError(RoundDateOrDateTimeEr
788
788
  ##
789
789
 
790
790
 
791
- _TTime_co = TypeVar("_TTime_co", bound=Time | dt.time, covariant=True)
792
-
793
-
794
791
  @dataclass(repr=False, order=True, unsafe_hash=True, kw_only=False)
795
792
  class TimePeriod:
796
793
  """A period of times."""
@@ -817,7 +814,7 @@ class TimePeriod:
817
814
  return DatePeriod(start, end).at((self.start, self.end), time_zone=time_zone)
818
815
 
819
816
  @classmethod
820
- def from_dict(cls, mapping: PeriodDict[_TTime_co], /) -> Self:
817
+ def from_dict(cls, mapping: PeriodDict[Time] | PeriodDict[dt.time], /) -> Self:
821
818
  """Convert the dictionary to a period."""
822
819
  match mapping["start"]:
823
820
  case Time() as start:
@@ -845,6 +842,10 @@ class TimePeriod:
845
842
  """Convert the period to a dictionary."""
846
843
  return PeriodDict(start=self.start, end=self.end)
847
844
 
845
+ def to_py_dict(self) -> PeriodDict[dt.time]:
846
+ """Convert the period to a dictionary."""
847
+ return PeriodDict(start=self.start.py_time(), end=self.end.py_time())
848
+
848
849
 
849
850
  ##
850
851
 
@@ -1726,11 +1727,6 @@ class WheneverLogRecord(LogRecord):
1726
1727
  ##
1727
1728
 
1728
1729
 
1729
- _TDateTime_co = TypeVar(
1730
- "_TDateTime_co", bound=ZonedDateTime | dt.datetime, covariant=True
1731
- )
1732
-
1733
-
1734
1730
  @dataclass(repr=False, order=True, unsafe_hash=True, kw_only=False)
1735
1731
  class ZonedDateTimePeriod:
1736
1732
  """A period of time."""
@@ -1833,7 +1829,9 @@ class ZonedDateTimePeriod:
1833
1829
  return f"{fc(start.to_plain())}-{fc(end, fmt='%Y%m%dT%H')}"
1834
1830
 
1835
1831
  @classmethod
1836
- def from_dict(cls, mapping: PeriodDict[_TDateTime_co], /) -> Self:
1832
+ def from_dict(
1833
+ cls, mapping: PeriodDict[ZonedDateTime] | PeriodDict[dt.datetime], /
1834
+ ) -> Self:
1837
1835
  """Convert the dictionary to a period."""
1838
1836
  match mapping["start"]:
1839
1837
  case ZonedDateTime() as start:
@@ -1869,6 +1867,10 @@ class ZonedDateTimePeriod:
1869
1867
  """Convert the period to a dictionary."""
1870
1868
  return PeriodDict(start=self.start, end=self.end)
1871
1869
 
1870
+ def to_py_dict(self) -> PeriodDict[dt.datetime]:
1871
+ """Convert the period to a dictionary."""
1872
+ return PeriodDict(start=self.start.py_datetime(), end=self.end.py_datetime())
1873
+
1872
1874
  def to_tz(self, time_zone: TimeZoneLike, /) -> Self:
1873
1875
  """Convert the time zone."""
1874
1876
  tz = to_time_zone_name(time_zone)