dycw-utilities 0.153.0__py3-none-any.whl → 0.153.1__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.153.0
3
+ Version: 0.153.1
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=YrB57gAJ2Dww1DzS0Q40Af0w6OpW_7druYx52IhzCcI,60
1
+ utilities/__init__.py,sha256=tLMJ7LzsnMye2vQj1HzCBHT0fuYeBMXUcof9VDP_uyk,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,7 +69,7 @@ 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=DVu1Cf2hdOyHbCZv56aPBDyjhT9HVSS8ko32YmqMVxM,12526
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
@@ -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.0.dist-info/METADATA,sha256=okQ-pxHQYem5BZer9IWNEOcPMJmwknoEv2SFJTHP8Ck,1696
91
- dycw_utilities-0.153.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
92
- dycw_utilities-0.153.0.dist-info/entry_points.txt,sha256=BOD_SoDxwsfJYOLxhrSXhHP_T7iw-HXI9f2WVkzYxvQ,135
93
- dycw_utilities-0.153.0.dist-info/licenses/LICENSE,sha256=gppZp16M6nSVpBbUBrNL6JuYfvKwZiKgV7XoKKsHzqo,1066
94
- dycw_utilities-0.153.0.dist-info/RECORD,,
90
+ dycw_utilities-0.153.1.dist-info/METADATA,sha256=5qPYBod9hSVQarpW6SVN-iqMQgPfp9YYT6u5wPGAAVk,1696
91
+ dycw_utilities-0.153.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
92
+ dycw_utilities-0.153.1.dist-info/entry_points.txt,sha256=BOD_SoDxwsfJYOLxhrSXhHP_T7iw-HXI9f2WVkzYxvQ,135
93
+ dycw_utilities-0.153.1.dist-info/licenses/LICENSE,sha256=gppZp16M6nSVpBbUBrNL6JuYfvKwZiKgV7XoKKsHzqo,1066
94
+ dycw_utilities-0.153.1.dist-info/RECORD,,
utilities/__init__.py CHANGED
@@ -1,3 +1,3 @@
1
1
  from __future__ import annotations
2
2
 
3
- __version__ = "0.153.0"
3
+ __version__ = "0.153.1"
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
  ]