dycw-utilities 0.155.4__py3-none-any.whl → 0.156.0__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.155.4
3
+ Version: 0.156.0
4
4
  Author-email: Derek Wan <d.wan@icloud.com>
5
5
  License-File: LICENSE
6
6
  Requires-Python: >=3.12
@@ -1,10 +1,10 @@
1
- utilities/__init__.py,sha256=JZDiFrW90kp6d38qwQIEOcE7Gd8ts-n5Mjx7Ed2T8zc,60
1
+ utilities/__init__.py,sha256=qnrT_UTHUY5w9TUoe2Wq56gzkzQRpi_K6c4hWJV6mLs,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
5
5
  utilities/atools.py,sha256=6neeCcgXxK2dlsc0xp15Za7nSucbCgFtAJepGI_-WXU,2549
6
6
  utilities/cachetools.py,sha256=v1-9sXHLdOLiwmkq6NB0OUbxeKBuVVN6wmAWefWoaHI,2744
7
- utilities/click.py,sha256=NXGzWoFOJqIblGwFqSGgXEDCKoV8E_JR58Lu2xJJFAo,17309
7
+ utilities/click.py,sha256=yw81P1OC2Z-4j-5y2sfvLtCNMZDAY6IQ8sjyKvd8hW8,17594
8
8
  utilities/concurrent.py,sha256=fHeW2SZ_TEMfFY0C8pyQI6aPlnecvx9x6SuUwBWj_JY,2853
9
9
  utilities/contextlib.py,sha256=m2D5bwvtCZLJcJ3IwVqyErYODuwJ1gLrT2UfATAQl-w,7435
10
10
  utilities/contextvars.py,sha256=J8OhC7jqozAGYOCe2KUWysbPXNGe5JYz3HfaY_mIs08,883
@@ -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.155.4.dist-info/METADATA,sha256=zStuqB5LeQevJmpVVzbnSRhmBY8h9OGkYNoTAsm4DVA,1643
91
- dycw_utilities-0.155.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
92
- dycw_utilities-0.155.4.dist-info/entry_points.txt,sha256=BOD_SoDxwsfJYOLxhrSXhHP_T7iw-HXI9f2WVkzYxvQ,135
93
- dycw_utilities-0.155.4.dist-info/licenses/LICENSE,sha256=gppZp16M6nSVpBbUBrNL6JuYfvKwZiKgV7XoKKsHzqo,1066
94
- dycw_utilities-0.155.4.dist-info/RECORD,,
90
+ dycw_utilities-0.156.0.dist-info/METADATA,sha256=J71C9d7mzvc5tHFVLEmcOD0NLrPbS5D8zkpnRwq5AEg,1643
91
+ dycw_utilities-0.156.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
92
+ dycw_utilities-0.156.0.dist-info/entry_points.txt,sha256=BOD_SoDxwsfJYOLxhrSXhHP_T7iw-HXI9f2WVkzYxvQ,135
93
+ dycw_utilities-0.156.0.dist-info/licenses/LICENSE,sha256=gppZp16M6nSVpBbUBrNL6JuYfvKwZiKgV7XoKKsHzqo,1066
94
+ dycw_utilities-0.156.0.dist-info/RECORD,,
utilities/__init__.py CHANGED
@@ -1,3 +1,3 @@
1
1
  from __future__ import annotations
2
2
 
3
- __version__ = "0.155.4"
3
+ __version__ = "0.156.0"
utilities/click.py CHANGED
@@ -6,7 +6,6 @@ import pathlib
6
6
  import uuid
7
7
  from typing import TYPE_CHECKING, TypedDict, assert_never, override
8
8
 
9
- import click
10
9
  import whenever
11
10
  from click import Choice, Context, Parameter, ParamType
12
11
  from click.types import IntParamType, StringParamType
@@ -29,6 +28,7 @@ if TYPE_CHECKING:
29
28
  IPv6AddressLike,
30
29
  MaybeStr,
31
30
  MonthDayLike,
31
+ PathLike,
32
32
  PlainDateTimeLike,
33
33
  TimeDeltaLike,
34
34
  TimeLike,
@@ -37,16 +37,6 @@ if TYPE_CHECKING:
37
37
  )
38
38
 
39
39
 
40
- FilePath = click.Path(file_okay=True, dir_okay=False, path_type=pathlib.Path)
41
- DirPath = click.Path(file_okay=False, dir_okay=True, path_type=pathlib.Path)
42
- ExistingFilePath = click.Path(
43
- exists=True, file_okay=True, dir_okay=False, path_type=pathlib.Path
44
- )
45
- ExistingDirPath = click.Path(
46
- exists=True, file_okay=False, dir_okay=True, path_type=pathlib.Path
47
- )
48
-
49
-
50
40
  class _HelpOptionNames(TypedDict):
51
41
  help_option_names: Sequence[str]
52
42
 
@@ -252,6 +242,32 @@ class MonthDay(ParamType):
252
242
  assert_never(never)
253
243
 
254
244
 
245
+ class Path(ParamType):
246
+ """A path-valued parameter."""
247
+
248
+ name = "path"
249
+
250
+ @override
251
+ def __repr__(self) -> str:
252
+ return self.name.upper()
253
+
254
+ @override
255
+ def convert(
256
+ self, value: PathLike, param: Parameter | None, ctx: Context | None
257
+ ) -> pathlib.Path:
258
+ """Convert a value into the `Path` type."""
259
+ match value:
260
+ case pathlib.Path():
261
+ return value.expanduser()
262
+ case str():
263
+ try:
264
+ return pathlib.Path(value).expanduser()
265
+ except ValueError as error:
266
+ self.fail(str(error), param, ctx)
267
+ case never:
268
+ assert_never(never)
269
+
270
+
255
271
  class PlainDateTime(ParamType):
256
272
  """A local-datetime-valued parameter."""
257
273
 
@@ -592,11 +608,7 @@ __all__ = [
592
608
  "Date",
593
609
  "DateDelta",
594
610
  "DateTimeDelta",
595
- "DirPath",
596
611
  "Enum",
597
- "ExistingDirPath",
598
- "ExistingFilePath",
599
- "FilePath",
600
612
  "FrozenSetChoices",
601
613
  "FrozenSetEnums",
602
614
  "FrozenSetParameter",
@@ -609,6 +621,8 @@ __all__ = [
609
621
  "ListParameter",
610
622
  "ListStrs",
611
623
  "MonthDay",
624
+ "Path",
625
+ "Path",
612
626
  "PlainDateTime",
613
627
  "Time",
614
628
  "TimeDelta",