click-extended 0.1.1__py3-none-any.whl → 0.2.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.
click_extended/errors.py CHANGED
@@ -10,6 +10,8 @@ from click import ClickException
10
10
  from click._compat import get_text_stderr
11
11
  from click.utils import echo
12
12
 
13
+ from click_extended.utils.format import format_list
14
+
13
15
 
14
16
  class ClickExtendedError(Exception):
15
17
  """Base exception for exceptions defined in the `click_extended` library."""
@@ -47,7 +49,7 @@ class ParameterError(ClickException):
47
49
  and adding parameter context information.
48
50
  """
49
51
 
50
- exit_code = 2 # Match Click's UsageError exit code
52
+ exit_code = 2
51
53
 
52
54
  def __init__(
53
55
  self,
@@ -59,9 +61,12 @@ class ParameterError(ClickException):
59
61
  Initialize a ParameterError.
60
62
 
61
63
  Args:
62
- message: The error message from the validator/transformer.
63
- param_hint: The parameter name (e.g., '--config', 'PATH').
64
- ctx: The Click context for displaying usage information.
64
+ message (str):
65
+ The error message from the validator/transformer.
66
+ param_hint (str, optional):
67
+ The parameter name (e.g., '--config', 'PATH').
68
+ ctx (click.Context, optional):
69
+ The Click context for displaying usage information.
65
70
  """
66
71
  super().__init__(message)
67
72
  self.param_hint = param_hint
@@ -235,12 +240,18 @@ class TypeMismatchError(ClickExtendedError):
235
240
  """Get type name, handling both regular types and UnionType."""
236
241
  return getattr(type_obj, "__name__", str(type_obj))
237
242
 
238
- type_names = ", ".join(get_type_name(t) for t in supported_types)
239
243
  parent_type_name = get_type_name(parent_type) if parent_type else "None"
240
244
 
245
+ type_names = [get_type_name(t) for t in supported_types]
246
+ formatted_types = format_list(
247
+ type_names,
248
+ prefix_singular="Supported type is ",
249
+ prefix_plural="Supported types are ",
250
+ )
251
+
241
252
  message = (
242
253
  f"Decorator '{name}' does not support "
243
254
  f"parent '{parent_name}' with type '{parent_type_name}'. "
244
- f"Supported types: {type_names}"
255
+ f"{formatted_types}"
245
256
  )
246
257
  super().__init__(message)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: click_extended
3
- Version: 0.1.1
3
+ Version: 0.2.0
4
4
  Summary: An extension to Click with additional features like automatic async support, aliasing and a modular decorator system.
5
5
  Author-email: Marcus Fredriksson <marcus@marcusfredriksson.com>
6
6
  License: MIT License
@@ -0,0 +1,9 @@
1
+ click_extended/__init__.py,sha256=wBUV7-CmgDBKSnDj3_MbYCjHv2zAaATQ795Y9Xs-0NE,858
2
+ click_extended/errors.py,sha256=HrUVB7RiTrVY5arphT0exB2w5qKU2GJrI1BwEJ1W0kg,8038
3
+ click_extended/types.py,sha256=tiz-toTYABwFTsxUMIDRhPiq3H_V3nhrAcV8VGEKyzA,786
4
+ click_extended-0.2.0.dist-info/licenses/AUTHORS.md,sha256=NkShPinjqtnRDQVRyVnfJuOGM56sejauE3WRoYCcbtw,132
5
+ click_extended-0.2.0.dist-info/licenses/LICENSE,sha256=gjO8hzM4mFSBXFikktaXVSgmXGcre91_GPJ-E_yP56E,1075
6
+ click_extended-0.2.0.dist-info/METADATA,sha256=VCiGXSuS0ZxzBCp3roGLKMEDJSwoT-zdHfD42PmOEV0,8295
7
+ click_extended-0.2.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
8
+ click_extended-0.2.0.dist-info/top_level.txt,sha256=2G3bm6tCNv80okRm773jKTk-_z1ElY-seaozZrn_TxA,15
9
+ click_extended-0.2.0.dist-info/RECORD,,
@@ -1,9 +0,0 @@
1
- click_extended/__init__.py,sha256=wBUV7-CmgDBKSnDj3_MbYCjHv2zAaATQ795Y9Xs-0NE,858
2
- click_extended/errors.py,sha256=hHKYsi61__uksU33-S80gANZg2ZsoHGhLdz6qR49r-I,7774
3
- click_extended/types.py,sha256=tiz-toTYABwFTsxUMIDRhPiq3H_V3nhrAcV8VGEKyzA,786
4
- click_extended-0.1.1.dist-info/licenses/AUTHORS.md,sha256=NkShPinjqtnRDQVRyVnfJuOGM56sejauE3WRoYCcbtw,132
5
- click_extended-0.1.1.dist-info/licenses/LICENSE,sha256=gjO8hzM4mFSBXFikktaXVSgmXGcre91_GPJ-E_yP56E,1075
6
- click_extended-0.1.1.dist-info/METADATA,sha256=Wad4ceCPVbnjXs9CmrCRYVDyz6KXzj6FGUIiNZwOdLA,8295
7
- click_extended-0.1.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
8
- click_extended-0.1.1.dist-info/top_level.txt,sha256=2G3bm6tCNv80okRm773jKTk-_z1ElY-seaozZrn_TxA,15
9
- click_extended-0.1.1.dist-info/RECORD,,