dycw-utilities 0.136.6__py3-none-any.whl → 0.136.8__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.136.6
3
+ Version: 0.136.8
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=AkTwc_IslcficXaKXyPr9mQYVL_PcizHlUpq1xo5QTc,60
1
+ utilities/__init__.py,sha256=LoQF7frj1FsC8oJrGrNGBrr9qRbSyAYP8xZLub7u6hI,60
2
2
  utilities/aiolimiter.py,sha256=mD0wEiqMgwpty4XTbawFpnkkmJS6R4JRsVXFUaoitSU,628
3
3
  utilities/altair.py,sha256=HeZBVUocjkrTNwwKrClppsIqgNFF-ykv05HfZSoHYno,9104
4
4
  utilities/asyncio.py,sha256=dcGeKQzjLBXxKzZkVIk5oZsFXEcynVbRB9iNB5XEDZk,38526
@@ -36,7 +36,7 @@ utilities/luigi.py,sha256=wK7cB3y8NXeSa8d6r_yTKRmjMguNmIPmy52yg10vPaI,4774
36
36
  utilities/math.py,sha256=_6vrDyjtaqE_OFE-F2DNWrDG_J_kMl3nFAJsok9v_bY,26862
37
37
  utilities/memory_profiler.py,sha256=XzN56jDCa5aqXS_DxEjb_K4L6aIWh_5zyKi6OhcIxw0,853
38
38
  utilities/modules.py,sha256=iuvLluJya-hvl1Q25-Jk3dLgx2Es3ck4SjJiEkAlVTs,3195
39
- utilities/more_itertools.py,sha256=EX4P5JTc3p9fF3Ia3ZzPy9CEUe6OZcFqrrVplZ4pMaQ,10937
39
+ utilities/more_itertools.py,sha256=NEGXDT8COaxziaJFTiXYKX0gffwfKhCAMrq-Kgh0w8c,10937
40
40
  utilities/numpy.py,sha256=Xn23sA2ZbVNqwUYEgNJD3XBYH6IbCri_WkHSNhg3NkY,26122
41
41
  utilities/operator.py,sha256=fZM2DBZdjtU8Lh9Z-eHC4ktNr0vO3JfX8hXgIYwdvBI,3826
42
42
  utilities/optuna.py,sha256=C-fhWYiXHVPo1l8QctYkFJ4DyhbSrGorzP1dJb_qvd8,1933
@@ -67,7 +67,7 @@ utilities/sentinel.py,sha256=3jIwgpMekWgDAxPDA_hXMP2St43cPhciKN3LWiZ7kv0,1248
67
67
  utilities/shelve.py,sha256=HZsMwK4tcIfg3sh0gApx4-yjQnrY4o3V3ZRimvRhoW0,738
68
68
  utilities/slack_sdk.py,sha256=RrB34gOj4TzBFh1vzMy6wL_ajzIG-2c9kiS6c6LzMFM,4233
69
69
  utilities/socket.py,sha256=K77vfREvzoVTrpYKo6MZakol0EYu2q1sWJnnZqL0So0,118
70
- utilities/sqlalchemy.py,sha256=NAJGgCqdLoqPZIne74M3Z_sOaNYVEXiIhl3-6p-4UZE,38219
70
+ utilities/sqlalchemy.py,sha256=wZU8k_Mdi2v9U8bmqy3W3EiQywvrPj_wL24L1coTYRk,38565
71
71
  utilities/sqlalchemy_polars.py,sha256=jXO-yizGuX_mivaQg7pe17GldcTMpeEldkIL4SpMyuI,14294
72
72
  utilities/statsmodels.py,sha256=koyiBHvpMcSiBfh99wFUfSggLNx7cuAw3rwyfAhoKpQ,3410
73
73
  utilities/streamlit.py,sha256=U9PJBaKP1IdSykKhPZhIzSPTZsmLsnwbEPZWzNhJPKk,2955
@@ -88,7 +88,7 @@ utilities/warnings.py,sha256=un1LvHv70PU-LLv8RxPVmugTzDJkkGXRMZTE2-fTQHw,1771
88
88
  utilities/whenever.py,sha256=A-yoOqBqrcVD1yDINDsTFDw7dq9-zgUGn_f8CxVUQJs,23332
89
89
  utilities/zipfile.py,sha256=24lQc9ATcJxHXBPc_tBDiJk48pWyRrlxO2fIsFxU0A8,699
90
90
  utilities/zoneinfo.py,sha256=oEH-nL3t4h9uawyZqWDtNtDAl6M-CLpLYGI_nI6DulM,1971
91
- dycw_utilities-0.136.6.dist-info/METADATA,sha256=abfQoeh81tTgbJfqO9Sh2xjiQ-Vj3pAI_jR9eOHdnGw,1637
92
- dycw_utilities-0.136.6.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
93
- dycw_utilities-0.136.6.dist-info/licenses/LICENSE,sha256=gppZp16M6nSVpBbUBrNL6JuYfvKwZiKgV7XoKKsHzqo,1066
94
- dycw_utilities-0.136.6.dist-info/RECORD,,
91
+ dycw_utilities-0.136.8.dist-info/METADATA,sha256=rKDsTulyR9hUod-Rdng5s8hRoRgfivymmIuqq1TU-CA,1637
92
+ dycw_utilities-0.136.8.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
93
+ dycw_utilities-0.136.8.dist-info/licenses/LICENSE,sha256=gppZp16M6nSVpBbUBrNL6JuYfvKwZiKgV7XoKKsHzqo,1066
94
+ dycw_utilities-0.136.8.dist-info/RECORD,,
utilities/__init__.py CHANGED
@@ -1,3 +1,3 @@
1
1
  from __future__ import annotations
2
2
 
3
- __version__ = "0.136.6"
3
+ __version__ = "0.136.8"
@@ -28,50 +28,59 @@ if TYPE_CHECKING:
28
28
 
29
29
 
30
30
  @overload
31
- def bucket_mapping[T, U, UH: Hashable](
31
+ def bucket_mapping[T, UH: Hashable](
32
32
  iterable: Iterable[T],
33
33
  func: Callable[[T], UH],
34
34
  /,
35
35
  *,
36
- pre: Callable[[T], U],
36
+ pre: None = None,
37
+ post: None = None,
38
+ ) -> Mapping[UH, Iterator[T]]: ...
39
+ @overload
40
+ def bucket_mapping[T, UH: Hashable](
41
+ iterable: Iterable[T],
42
+ func: Callable[[T], UH],
43
+ /,
44
+ *,
45
+ pre: None = None,
37
46
  post: Literal["list"],
38
- ) -> Mapping[UH, list[U]]: ...
47
+ ) -> Mapping[UH, list[T]]: ...
39
48
  @overload
40
- def bucket_mapping[T, U, UH: Hashable](
49
+ def bucket_mapping[T, UH: Hashable](
41
50
  iterable: Iterable[T],
42
51
  func: Callable[[T], UH],
43
52
  /,
44
53
  *,
45
- pre: Callable[[T], U],
54
+ pre: None = None,
46
55
  post: Literal["tuple"],
47
- ) -> Mapping[UH, tuple[U, ...]]: ...
56
+ ) -> Mapping[UH, tuple[T, ...]]: ...
48
57
  @overload
49
- def bucket_mapping[T, U, UH: Hashable](
58
+ def bucket_mapping[T, UH: Hashable](
50
59
  iterable: Iterable[T],
51
60
  func: Callable[[T], UH],
52
61
  /,
53
62
  *,
54
- pre: Callable[[T], U],
63
+ pre: None = None,
55
64
  post: Literal["set"],
56
- ) -> Mapping[UH, set[U]]: ...
65
+ ) -> Mapping[UH, set[T]]: ...
57
66
  @overload
58
- def bucket_mapping[T, U, UH: Hashable](
67
+ def bucket_mapping[T, UH: Hashable](
59
68
  iterable: Iterable[T],
60
69
  func: Callable[[T], UH],
61
70
  /,
62
71
  *,
63
- pre: Callable[[T], U],
72
+ pre: None = None,
64
73
  post: Literal["frozenset"],
65
- ) -> Mapping[UH, frozenset[U]]: ...
74
+ ) -> Mapping[UH, frozenset[T]]: ...
66
75
  @overload
67
- def bucket_mapping[T, U, UH: Hashable](
76
+ def bucket_mapping[T, UH: Hashable](
68
77
  iterable: Iterable[T],
69
78
  func: Callable[[T], UH],
70
79
  /,
71
80
  *,
72
- pre: Callable[[T], U] | None = None,
81
+ pre: None = None,
73
82
  post: Literal["unique"],
74
- ) -> Mapping[UH, U]: ...
83
+ ) -> Mapping[UH, T]: ...
75
84
  @overload
76
85
  def bucket_mapping[T, U, UH: Hashable](
77
86
  iterable: Iterable[T],
@@ -82,59 +91,50 @@ def bucket_mapping[T, U, UH: Hashable](
82
91
  post: None = None,
83
92
  ) -> Mapping[UH, Iterator[U]]: ...
84
93
  @overload
85
- def bucket_mapping[T, UH: Hashable](
94
+ def bucket_mapping[T, U, UH: Hashable](
86
95
  iterable: Iterable[T],
87
96
  func: Callable[[T], UH],
88
97
  /,
89
98
  *,
90
- pre: None = None,
99
+ pre: Callable[[T], U],
91
100
  post: Literal["list"],
92
- ) -> Mapping[UH, list[T]]: ...
101
+ ) -> Mapping[UH, list[U]]: ...
93
102
  @overload
94
- def bucket_mapping[T, UH: Hashable](
103
+ def bucket_mapping[T, U, UH: Hashable](
95
104
  iterable: Iterable[T],
96
105
  func: Callable[[T], UH],
97
106
  /,
98
107
  *,
99
- pre: None = None,
108
+ pre: Callable[[T], U],
100
109
  post: Literal["tuple"],
101
- ) -> Mapping[UH, tuple[T, ...]]: ...
110
+ ) -> Mapping[UH, tuple[U, ...]]: ...
102
111
  @overload
103
- def bucket_mapping[T, UH: Hashable](
112
+ def bucket_mapping[T, U, UH: Hashable](
104
113
  iterable: Iterable[T],
105
114
  func: Callable[[T], UH],
106
115
  /,
107
116
  *,
108
- pre: None = None,
117
+ pre: Callable[[T], U],
109
118
  post: Literal["set"],
110
- ) -> Mapping[UH, set[T]]: ...
119
+ ) -> Mapping[UH, set[U]]: ...
111
120
  @overload
112
- def bucket_mapping[T, UH: Hashable](
121
+ def bucket_mapping[T, U, UH: Hashable](
113
122
  iterable: Iterable[T],
114
123
  func: Callable[[T], UH],
115
124
  /,
116
125
  *,
117
- pre: None = None,
126
+ pre: Callable[[T], U],
118
127
  post: Literal["frozenset"],
119
- ) -> Mapping[UH, frozenset[T]]: ...
128
+ ) -> Mapping[UH, frozenset[U]]: ...
120
129
  @overload
121
- def bucket_mapping[T, UH: Hashable](
130
+ def bucket_mapping[T, U, UH: Hashable](
122
131
  iterable: Iterable[T],
123
132
  func: Callable[[T], UH],
124
133
  /,
125
134
  *,
126
- pre: None = None,
135
+ pre: Callable[[T], U] | None = None,
127
136
  post: Literal["unique"],
128
- ) -> Mapping[UH, T]: ...
129
- @overload
130
- def bucket_mapping[T, UH: Hashable](
131
- iterable: Iterable[T],
132
- func: Callable[[T], UH],
133
- /,
134
- *,
135
- pre: None = None,
136
- post: None = None,
137
- ) -> Mapping[UH, Iterator[T]]: ...
137
+ ) -> Mapping[UH, U]: ...
138
138
  @overload
139
139
  def bucket_mapping[T, U, UH: Hashable](
140
140
  iterable: Iterable[T],
utilities/sqlalchemy.py CHANGED
@@ -86,6 +86,8 @@ from utilities.types import MaybeIterable, MaybeType, StrMapping, TupleOrStrMapp
86
86
  from utilities.whenever import SECOND
87
87
 
88
88
  if TYPE_CHECKING:
89
+ from enum import Enum, StrEnum
90
+
89
91
  from whenever import TimeDelta
90
92
 
91
93
  type _EngineOrConnectionOrAsync = Engine | Connection | AsyncEngine | AsyncConnection
@@ -284,6 +286,22 @@ async def ensure_tables_dropped(
284
286
  ##
285
287
 
286
288
 
289
+ def enum_name(enum: type[Enum], /) -> str:
290
+ """Get the name of an Enum."""
291
+ return f"{snake_case(get_class_name(enum))}_enum"
292
+
293
+
294
+ ##
295
+
296
+
297
+ def enum_values(enum: type[StrEnum], /) -> list[str]:
298
+ """Get the values of a StrEnum."""
299
+ return [e.value for e in enum]
300
+
301
+
302
+ ##
303
+
304
+
287
305
  def get_chunk_size(
288
306
  engine_or_conn: _EngineOrConnectionOrAsync,
289
307
  /,
@@ -1171,6 +1189,8 @@ __all__ = [
1171
1189
  "create_async_engine",
1172
1190
  "ensure_tables_created",
1173
1191
  "ensure_tables_dropped",
1192
+ "enum_name",
1193
+ "enum_values",
1174
1194
  "get_chunk_size",
1175
1195
  "get_column_names",
1176
1196
  "get_columns",