MCPcopy Create free account
hub / github.com/python-cmd2/cmd2 / build_range_error

Function build_range_error

cmd2/argparse_utils.py:268–284  ·  view source on GitHub ↗

Build an error message when the the number of arguments provided is not within the expected range.

(range_min: int, range_max: float)

Source from the content-addressed store, hash-verified

266
267
268def build_range_error(range_min: int, range_max: float) -> str:
269 """Build an error message when the the number of arguments provided is not within the expected range."""
270 err_msg = "expected "
271
272 if range_max == constants.INFINITY:
273 plural = "" if range_min == 1 else "s"
274 err_msg += f"at least {range_min}"
275 else:
276 plural = "" if range_max == 1 else "s"
277 if range_min == range_max:
278 err_msg += f"{range_min}"
279 else:
280 err_msg += f"{range_min} to {range_max}"
281
282 err_msg += f" argument{plural}"
283
284 return err_msg
285
286
287############################################################################################################

Callers 3

test_build_range_errorFunction · 0.90
_match_argumentMethod · 0.85
__init__Method · 0.85

Calls

no outgoing calls

Tested by 1

test_build_range_errorFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…