dycw-utilities 0.153.0__py3-none-any.whl → 0.153.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.
- {dycw_utilities-0.153.0.dist-info → dycw_utilities-0.153.2.dist-info}/METADATA +1 -1
- {dycw_utilities-0.153.0.dist-info → dycw_utilities-0.153.2.dist-info}/RECORD +8 -8
- utilities/__init__.py +1 -1
- utilities/text.py +22 -1
- utilities/types.py +8 -6
- {dycw_utilities-0.153.0.dist-info → dycw_utilities-0.153.2.dist-info}/WHEEL +0 -0
- {dycw_utilities-0.153.0.dist-info → dycw_utilities-0.153.2.dist-info}/entry_points.txt +0 -0
- {dycw_utilities-0.153.0.dist-info → dycw_utilities-0.153.2.dist-info}/licenses/LICENSE +0 -0
@@ -1,4 +1,4 @@
|
|
1
|
-
utilities/__init__.py,sha256=
|
1
|
+
utilities/__init__.py,sha256=BOz9C-obZ9rIhyLSCVDsOVjnOeSdkl-YhkX0PSDH0-A,60
|
2
2
|
utilities/altair.py,sha256=92E2lCdyHY4Zb-vCw6rEJIsWdKipuu-Tu2ab1ufUfAk,9079
|
3
3
|
utilities/asyncio.py,sha256=QXkTtugXkqtYt7Do23zgYErqzdp6jwzPpV_SP9fJ1gI,16780
|
4
4
|
utilities/atomicwrites.py,sha256=tPo6r-Rypd9u99u66B9z86YBPpnLrlHtwox_8Z7T34Y,5790
|
@@ -69,12 +69,12 @@ utilities/sqlalchemy_polars.py,sha256=Mm-sShZfqqgnzTrupMQdCfSM2akrybXHXAErTs-ofM
|
|
69
69
|
utilities/statsmodels.py,sha256=koyiBHvpMcSiBfh99wFUfSggLNx7cuAw3rwyfAhoKpQ,3410
|
70
70
|
utilities/string.py,sha256=shmBK87zZwzGyixuNuXCiUbqzfeZ9xlrFwz6JTaRvDk,582
|
71
71
|
utilities/tempfile.py,sha256=HxB2BF28CcecDJLQ3Bx2Ej-Pb6RJc6W9ngSpB9CnP4k,2018
|
72
|
-
utilities/text.py,sha256=
|
72
|
+
utilities/text.py,sha256=uwCDgpEunYruyh6sKMfNWK3Rp5H3ndpKRAkq86CBNys,13043
|
73
73
|
utilities/threading.py,sha256=GvBOp4CyhHfN90wGXZuA2VKe9fGzMaEa7oCl4f3nnPU,1009
|
74
74
|
utilities/timer.py,sha256=oXfTii6ymu57niP0BDGZjFD55LEHi2a19kqZKiTgaFQ,2588
|
75
75
|
utilities/traceback.py,sha256=e0BpxNMybVmELHGsYM5N6LVbfmn0jLhefLoa81NjZBg,9100
|
76
76
|
utilities/typed_settings.py,sha256=SFWqS3lAzV7IfNRwqFcTk0YynTcQ7BmrcW2mr_KUnos,4466
|
77
|
-
utilities/types.py,sha256=
|
77
|
+
utilities/types.py,sha256=SE5UTkI7EVdg_gVehgn9fRQ7TAOi2C1LpEm8qLIhZcs,18455
|
78
78
|
utilities/typing.py,sha256=Z-_XDaWyT_6wIo3qfNK-hvRlzxP2Jxa9PgXzm5rDYRA,13790
|
79
79
|
utilities/tzdata.py,sha256=fgNVj66yUbCSI_-vrRVzSD3gtf-L_8IEJEPjP_Jel5Y,266
|
80
80
|
utilities/tzlocal.py,sha256=KyCXEgCTjqGFx-389JdTuhMRUaT06U1RCMdWoED-qro,728
|
@@ -87,8 +87,8 @@ utilities/zoneinfo.py,sha256=FBMcUQ4662Aq8SsuCL1OAhDQiyANmVjtb-C30DRrWoE,1966
|
|
87
87
|
utilities/pytest_plugins/__init__.py,sha256=U4S_2y3zgLZVfMenHRaJFBW8yqh2mUBuI291LGQVOJ8,35
|
88
88
|
utilities/pytest_plugins/pytest_randomly.py,sha256=B1qYVlExGOxTywq2r1SMi5o7btHLk2PNdY_b1p98dkE,409
|
89
89
|
utilities/pytest_plugins/pytest_regressions.py,sha256=9v8kAXDM2ycIXJBimoiF4EgrwbUvxTycFWJiGR_GHhM,1466
|
90
|
-
dycw_utilities-0.153.
|
91
|
-
dycw_utilities-0.153.
|
92
|
-
dycw_utilities-0.153.
|
93
|
-
dycw_utilities-0.153.
|
94
|
-
dycw_utilities-0.153.
|
90
|
+
dycw_utilities-0.153.2.dist-info/METADATA,sha256=ZoTBo07vfu7uVKDOazdKRsN6QUwefZDYSLO15V1AAD4,1696
|
91
|
+
dycw_utilities-0.153.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
92
|
+
dycw_utilities-0.153.2.dist-info/entry_points.txt,sha256=BOD_SoDxwsfJYOLxhrSXhHP_T7iw-HXI9f2WVkzYxvQ,135
|
93
|
+
dycw_utilities-0.153.2.dist-info/licenses/LICENSE,sha256=gppZp16M6nSVpBbUBrNL6JuYfvKwZiKgV7XoKKsHzqo,1066
|
94
|
+
dycw_utilities-0.153.2.dist-info/RECORD,,
|
utilities/__init__.py
CHANGED
utilities/text.py
CHANGED
@@ -28,7 +28,7 @@ from utilities.sentinel import Sentinel
|
|
28
28
|
if TYPE_CHECKING:
|
29
29
|
from collections.abc import Iterable, Mapping, Sequence
|
30
30
|
|
31
|
-
from utilities.types import MaybeCallableBoolLike, StrStrMapping
|
31
|
+
from utilities.types import MaybeCallableBoolLike, MaybeCallableStr, StrStrMapping
|
32
32
|
|
33
33
|
|
34
34
|
DEFAULT_SEPARATOR = ","
|
@@ -462,6 +462,26 @@ def to_bool(
|
|
462
462
|
##
|
463
463
|
|
464
464
|
|
465
|
+
@overload
|
466
|
+
def to_str(text: MaybeCallableStr, /) -> str: ...
|
467
|
+
@overload
|
468
|
+
def to_str(text: None, /) -> None: ...
|
469
|
+
@overload
|
470
|
+
def to_str(text: Sentinel, /) -> Sentinel: ...
|
471
|
+
def to_str(text: MaybeCallableStr | None | Sentinel, /) -> str | None | Sentinel:
|
472
|
+
"""Convert to a string."""
|
473
|
+
match text:
|
474
|
+
case str() | None | Sentinel():
|
475
|
+
return text
|
476
|
+
case Callable() as func:
|
477
|
+
return to_str(func())
|
478
|
+
case never:
|
479
|
+
assert_never(never)
|
480
|
+
|
481
|
+
|
482
|
+
##
|
483
|
+
|
484
|
+
|
465
485
|
def unique_str() -> str:
|
466
486
|
"""Generate at unique string."""
|
467
487
|
now = time_ns()
|
@@ -491,5 +511,6 @@ __all__ = [
|
|
491
511
|
"str_encode",
|
492
512
|
"strip_and_dedent",
|
493
513
|
"to_bool",
|
514
|
+
"to_str",
|
494
515
|
"unique_str",
|
495
516
|
]
|
utilities/types.py
CHANGED
@@ -39,7 +39,6 @@ _T_contra = TypeVar("_T_contra", contravariant=True)
|
|
39
39
|
|
40
40
|
|
41
41
|
# basic
|
42
|
-
type BoolLike = MaybeStr[bool]
|
43
42
|
type OpenMode = Literal[
|
44
43
|
"r",
|
45
44
|
"w",
|
@@ -63,13 +62,15 @@ type OpenMode = Literal[
|
|
63
62
|
"a+b",
|
64
63
|
]
|
65
64
|
type MaybeCallable[T] = T | Callable[[], T]
|
66
|
-
type MaybeCallableBoolLike = MaybeCallable[BoolLike]
|
67
65
|
type MaybeStr[T] = T | str
|
68
66
|
type MaybeType[T] = T | type[T]
|
69
67
|
type StrMapping = Mapping[str, Any]
|
70
68
|
type StrStrMapping = Mapping[str, str]
|
71
|
-
type TypeLike[T] = type[T] | tuple[type[T], ...]
|
72
69
|
type TupleOrStrMapping = tuple[Any, ...] | StrMapping
|
70
|
+
type TypeLike[T] = type[T] | tuple[type[T], ...]
|
71
|
+
# basic - derived
|
72
|
+
type MaybeCallableBoolLike = MaybeCallable[BoolLike]
|
73
|
+
type BoolLike = MaybeStr[bool]
|
73
74
|
|
74
75
|
|
75
76
|
# asyncio
|
@@ -114,12 +115,12 @@ IPv6AddressLike = MaybeStr[IPv6Address]
|
|
114
115
|
|
115
116
|
|
116
117
|
# iterables
|
117
|
-
type SequenceLT[T] = list[T] | tuple[T, ...]
|
118
|
-
# iterables - maybe
|
119
118
|
type MaybeCollection[T] = T | Collection[T]
|
120
119
|
type MaybeIterable[T] = T | Iterable[T]
|
120
|
+
type MaybeList[T] = T | list[T]
|
121
|
+
type SequenceLT[T] = list[T] | tuple[T, ...]
|
122
|
+
# iterables - dervied
|
121
123
|
type MaybeSequence[T] = T | SequenceLT[T]
|
122
|
-
# iterables - str
|
123
124
|
type SequenceStr = SequenceLT[str]
|
124
125
|
type CollectionStr = dict[str, Any] | frozenset[str] | set[str] | SequenceStr
|
125
126
|
# iterables - maybe str
|
@@ -299,6 +300,7 @@ __all__ = [
|
|
299
300
|
"MaybeCollectionStr",
|
300
301
|
"MaybeCoro",
|
301
302
|
"MaybeIterable",
|
303
|
+
"MaybeList",
|
302
304
|
"MaybeSequence",
|
303
305
|
"MaybeSequenceStr",
|
304
306
|
"MaybeStr",
|
File without changes
|
File without changes
|
File without changes
|