dycw-utilities 0.151.2__py3-none-any.whl → 0.151.4__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.
- {dycw_utilities-0.151.2.dist-info → dycw_utilities-0.151.4.dist-info}/METADATA +1 -1
- {dycw_utilities-0.151.2.dist-info → dycw_utilities-0.151.4.dist-info}/RECORD +9 -9
- utilities/__init__.py +1 -1
- utilities/polars.py +28 -5
- utilities/postgres.py +27 -22
- utilities/types.py +10 -3
- {dycw_utilities-0.151.2.dist-info → dycw_utilities-0.151.4.dist-info}/WHEEL +0 -0
- {dycw_utilities-0.151.2.dist-info → dycw_utilities-0.151.4.dist-info}/entry_points.txt +0 -0
- {dycw_utilities-0.151.2.dist-info → dycw_utilities-0.151.4.dist-info}/licenses/LICENSE +0 -0
@@ -1,4 +1,4 @@
|
|
1
|
-
utilities/__init__.py,sha256=
|
1
|
+
utilities/__init__.py,sha256=AWZG62ObkkWl0zXPWFtqIU5oRl3bsTfN25MpOpwf7Pw,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
|
@@ -47,9 +47,9 @@ utilities/pathlib.py,sha256=FnteXeVeMOSc6QTN7oF6UrobjOX9gXv_5tG1slg83W8,8496
|
|
47
47
|
utilities/period.py,sha256=hsHdAKAstfMzB2Ar5EbxjkbMff3CA-B5wtYNVZOXVXI,10127
|
48
48
|
utilities/pickle.py,sha256=MBT2xZCsv0pH868IXLGKnlcqNx2IRVKYNpRcqiQQqxw,653
|
49
49
|
utilities/platform.py,sha256=Ue9LSxYvg9yUXGKuz5aZoy_qkUEXde-v6B09exgSctU,2813
|
50
|
-
utilities/polars.py,sha256=
|
50
|
+
utilities/polars.py,sha256=D9KzxCeLjqfv3dxplJtUuPKkyLbtPVcMHgMxL_im7tI,73313
|
51
51
|
utilities/polars_ols.py,sha256=Uc9V5kvlWZ5cU93lKZ-cfAKdVFFw81tqwLW9PxtUvMs,5618
|
52
|
-
utilities/postgres.py,sha256=
|
52
|
+
utilities/postgres.py,sha256=xArnonKtL5IR93LpoUYN2U16YswBCJlU5WQkDbv10A0,12553
|
53
53
|
utilities/pottery.py,sha256=u0uvyGgYyujxftEMlsv6ppYTKQoVVjHt5jnVxxYz9s4,6596
|
54
54
|
utilities/pqdm.py,sha256=BTsYPtbKQWwX-iXF4qCkfPG7DPxIB54J989n83bXrIo,3092
|
55
55
|
utilities/psutil.py,sha256=KUlu4lrUw9Zg1V7ZGetpWpGb9DB8l_SSDWGbANFNCPU,2104
|
@@ -76,7 +76,7 @@ utilities/threading.py,sha256=GvBOp4CyhHfN90wGXZuA2VKe9fGzMaEa7oCl4f3nnPU,1009
|
|
76
76
|
utilities/timer.py,sha256=oXfTii6ymu57niP0BDGZjFD55LEHi2a19kqZKiTgaFQ,2588
|
77
77
|
utilities/traceback.py,sha256=zofhzIedpUHrzDNiRJDVzm_wuu_tlTQvVqK4quxVlgM,9151
|
78
78
|
utilities/typed_settings.py,sha256=98OQQsXyfjxbGPjWqG45P_DoNgrzS4gZ7062oD2lgtE,4481
|
79
|
-
utilities/types.py,sha256=
|
79
|
+
utilities/types.py,sha256=4bHcAF4OVMjnaY9SAj8_bKiHfj6YurD6Y3cipV-5yFE,18551
|
80
80
|
utilities/typing.py,sha256=Z-_XDaWyT_6wIo3qfNK-hvRlzxP2Jxa9PgXzm5rDYRA,13790
|
81
81
|
utilities/tzdata.py,sha256=fgNVj66yUbCSI_-vrRVzSD3gtf-L_8IEJEPjP_Jel5Y,266
|
82
82
|
utilities/tzlocal.py,sha256=KyCXEgCTjqGFx-389JdTuhMRUaT06U1RCMdWoED-qro,728
|
@@ -89,8 +89,8 @@ 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.
|
93
|
-
dycw_utilities-0.151.
|
94
|
-
dycw_utilities-0.151.
|
95
|
-
dycw_utilities-0.151.
|
96
|
-
dycw_utilities-0.151.
|
92
|
+
dycw_utilities-0.151.4.dist-info/METADATA,sha256=kScCz13Y3Z7tccr7IxJmdugqwfG4c5Mmxfa4TB3XzT4,1696
|
93
|
+
dycw_utilities-0.151.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
94
|
+
dycw_utilities-0.151.4.dist-info/entry_points.txt,sha256=BOD_SoDxwsfJYOLxhrSXhHP_T7iw-HXI9f2WVkzYxvQ,135
|
95
|
+
dycw_utilities-0.151.4.dist-info/licenses/LICENSE,sha256=gppZp16M6nSVpBbUBrNL6JuYfvKwZiKgV7XoKKsHzqo,1066
|
96
|
+
dycw_utilities-0.151.4.dist-info/RECORD,,
|
utilities/__init__.py
CHANGED
utilities/polars.py
CHANGED
@@ -1340,11 +1340,22 @@ def get_data_type_or_series_time_zone(
|
|
1340
1340
|
dtype = series.dtype
|
1341
1341
|
case _ as never:
|
1342
1342
|
assert_never(never)
|
1343
|
-
|
1344
|
-
|
1345
|
-
|
1346
|
-
|
1347
|
-
|
1343
|
+
match dtype:
|
1344
|
+
case Datetime() as datetime:
|
1345
|
+
if datetime.time_zone is None:
|
1346
|
+
raise _GetDataTypeOrSeriesTimeZoneNotZonedError(dtype=datetime)
|
1347
|
+
return ZoneInfo(datetime.time_zone)
|
1348
|
+
case Struct() as struct:
|
1349
|
+
try:
|
1350
|
+
return one({
|
1351
|
+
get_data_type_or_series_time_zone(f.dtype) for f in struct.fields
|
1352
|
+
})
|
1353
|
+
except OneNonUniqueError as error:
|
1354
|
+
raise _GetDataTypeOrSeriesTimeZoneStructNonUniqueError(
|
1355
|
+
dtype=struct, first=error.first, second=error.second
|
1356
|
+
) from None
|
1357
|
+
case _:
|
1358
|
+
raise _GetDataTypeOrSeriesTimeZoneNotDateTimeError(dtype=dtype)
|
1348
1359
|
|
1349
1360
|
|
1350
1361
|
@dataclass(kw_only=True, slots=True)
|
@@ -1366,6 +1377,18 @@ class _GetDataTypeOrSeriesTimeZoneNotZonedError(GetDataTypeOrSeriesTimeZoneError
|
|
1366
1377
|
return f"Data type must be zoned; got {self.dtype}"
|
1367
1378
|
|
1368
1379
|
|
1380
|
+
@dataclass(kw_only=True, slots=True)
|
1381
|
+
class _GetDataTypeOrSeriesTimeZoneStructNonUniqueError(
|
1382
|
+
GetDataTypeOrSeriesTimeZoneError
|
1383
|
+
):
|
1384
|
+
first: ZoneInfo
|
1385
|
+
second: ZoneInfo
|
1386
|
+
|
1387
|
+
@override
|
1388
|
+
def __str__(self) -> str:
|
1389
|
+
return f"Struct data type must contain exactly one time zone; got {self.first}, {self.second} and perhaps more"
|
1390
|
+
|
1391
|
+
|
1369
1392
|
##
|
1370
1393
|
|
1371
1394
|
|
utilities/postgres.py
CHANGED
@@ -21,7 +21,12 @@ if TYPE_CHECKING:
|
|
21
21
|
from sqlalchemy import URL
|
22
22
|
|
23
23
|
from utilities.sqlalchemy import TableOrORMInstOrClass
|
24
|
-
from utilities.types import
|
24
|
+
from utilities.types import (
|
25
|
+
LoggerOrName,
|
26
|
+
MaybeCollection,
|
27
|
+
MaybeCollectionStr,
|
28
|
+
PathLike,
|
29
|
+
)
|
25
30
|
|
26
31
|
|
27
32
|
type _PGDumpFormat = Literal["plain", "custom", "directory", "tar"]
|
@@ -37,12 +42,12 @@ async def pg_dump(
|
|
37
42
|
data_only: bool = False,
|
38
43
|
clean: bool = False,
|
39
44
|
create: bool = False,
|
40
|
-
extension:
|
41
|
-
extension_exc:
|
42
|
-
schema:
|
43
|
-
schema_exc:
|
44
|
-
table:
|
45
|
-
table_exc:
|
45
|
+
extension: MaybeCollectionStr | None = None,
|
46
|
+
extension_exc: MaybeCollectionStr | None = None,
|
47
|
+
schema: MaybeCollectionStr | None = None,
|
48
|
+
schema_exc: MaybeCollectionStr | None = None,
|
49
|
+
table: MaybeCollection[TableOrORMInstOrClass | str] | None = None,
|
50
|
+
table_exc: MaybeCollection[TableOrORMInstOrClass | str] | None = None,
|
46
51
|
inserts: bool = False,
|
47
52
|
on_conflict_do_nothing: bool = False,
|
48
53
|
role: str | None = None,
|
@@ -113,12 +118,12 @@ def _build_pg_dump(
|
|
113
118
|
data_only: bool = False,
|
114
119
|
clean: bool = False,
|
115
120
|
create: bool = False,
|
116
|
-
extension:
|
117
|
-
extension_exc:
|
118
|
-
schema:
|
119
|
-
schema_exc:
|
120
|
-
table:
|
121
|
-
table_exc:
|
121
|
+
extension: MaybeCollectionStr | None = None,
|
122
|
+
extension_exc: MaybeCollectionStr | None = None,
|
123
|
+
schema: MaybeCollectionStr | None = None,
|
124
|
+
schema_exc: MaybeCollectionStr | None = None,
|
125
|
+
table: MaybeCollection[TableOrORMInstOrClass | str] | None = None,
|
126
|
+
table_exc: MaybeCollection[TableOrORMInstOrClass | str] | None = None,
|
122
127
|
inserts: bool = False,
|
123
128
|
on_conflict_do_nothing: bool = False,
|
124
129
|
role: str | None = None,
|
@@ -206,9 +211,9 @@ async def restore(
|
|
206
211
|
clean: bool = False,
|
207
212
|
create: bool = False,
|
208
213
|
jobs: int | None = None,
|
209
|
-
schema:
|
210
|
-
schema_exc:
|
211
|
-
table:
|
214
|
+
schema: MaybeCollectionStr | None = None,
|
215
|
+
schema_exc: MaybeCollectionStr | None = None,
|
216
|
+
table: MaybeCollection[TableOrORMInstOrClass | str] | None = None,
|
212
217
|
role: str | None = None,
|
213
218
|
docker: str | None = None,
|
214
219
|
dry_run: bool = False,
|
@@ -271,9 +276,9 @@ def _build_pg_restore_or_psql(
|
|
271
276
|
clean: bool = False,
|
272
277
|
create: bool = False,
|
273
278
|
jobs: int | None = None,
|
274
|
-
schema:
|
275
|
-
schema_exc:
|
276
|
-
table:
|
279
|
+
schema: MaybeCollectionStr | None = None,
|
280
|
+
schema_exc: MaybeCollectionStr | None = None,
|
281
|
+
table: MaybeCollection[TableOrORMInstOrClass | str] | None = None,
|
277
282
|
role: str | None = None,
|
278
283
|
docker: str | None = None,
|
279
284
|
) -> str:
|
@@ -304,9 +309,9 @@ def _build_pg_restore(
|
|
304
309
|
clean: bool = False,
|
305
310
|
create: bool = False,
|
306
311
|
jobs: int | None = None,
|
307
|
-
schemas:
|
308
|
-
schemas_exc:
|
309
|
-
tables:
|
312
|
+
schemas: MaybeCollectionStr | None = None,
|
313
|
+
schemas_exc: MaybeCollectionStr | None = None,
|
314
|
+
tables: MaybeCollection[TableOrORMInstOrClass | str] | None = None,
|
310
315
|
role: str | None = None,
|
311
316
|
docker: str | None = None,
|
312
317
|
) -> str:
|
utilities/types.py
CHANGED
@@ -123,15 +123,20 @@ IPv6AddressLike = MaybeStr[IPv6Address]
|
|
123
123
|
|
124
124
|
|
125
125
|
# iterables
|
126
|
-
type CollectionStr = frozenset[str] | list[str] | set[str] | tuple[str, ...]
|
127
126
|
type IterableHashable[T: Hashable] = tuple[T, ...] | frozenset[T]
|
128
127
|
type MaybeCollection[T] = T | Collection[T]
|
129
|
-
type MaybeCollectionStr = str | CollectionStr
|
130
128
|
type MaybeIterableHashable[T: Hashable] = T | IterableHashable[T]
|
131
129
|
type MaybeIterable[T] = T | Iterable[T]
|
132
|
-
type MaybeListStr = MaybeList[str]
|
133
130
|
type MaybeList[T] = T | list[T]
|
134
131
|
type MaybeSequence[T] = T | Sequence[T]
|
132
|
+
# iterables - str
|
133
|
+
type CollectionStr = (
|
134
|
+
dict[str, Any] | frozenset[str] | list[str] | set[str] | tuple[str, ...]
|
135
|
+
)
|
136
|
+
type MaybeCollectionStr = str | CollectionStr
|
137
|
+
type MaybeListStr = MaybeList[str]
|
138
|
+
type MaybeSequenceStr = str | SequenceStr
|
139
|
+
type SequenceStr = list[str] | tuple[str, ...]
|
135
140
|
|
136
141
|
|
137
142
|
# logging
|
@@ -302,6 +307,7 @@ __all__ = [
|
|
302
307
|
"MaybeList",
|
303
308
|
"MaybeListStr",
|
304
309
|
"MaybeSequence",
|
310
|
+
"MaybeSequenceStr",
|
305
311
|
"MaybeStr",
|
306
312
|
"MaybeType",
|
307
313
|
"MonthDayLike",
|
@@ -315,6 +321,7 @@ __all__ = [
|
|
315
321
|
"PatternLike",
|
316
322
|
"PlainDateTimeLike",
|
317
323
|
"Seed",
|
324
|
+
"SequenceStr",
|
318
325
|
"SerializeObjectExtra",
|
319
326
|
"Sign",
|
320
327
|
"StrMapping",
|
File without changes
|
File without changes
|
File without changes
|