MCPcopy Index your code
hub / github.com/RustPython/RustPython / _get_value

Method _get_value

Lib/argparse.py:2644–2666  ·  view source on GitHub ↗
(self, action, arg_string)

Source from the content-addressed store, hash-verified

2642 return value
2643
2644 def _get_value(self, action, arg_string):
2645 type_func = self._registry_get('type', action.type, action.type)
2646 if not callable(type_func):
2647 raise TypeError(f'{type_func!r} is not callable')
2648
2649 # convert the value to the appropriate type
2650 try:
2651 result = type_func(arg_string)
2652
2653 # ArgumentTypeErrors indicate errors
2654 except ArgumentTypeError as err:
2655 msg = str(err)
2656 raise ArgumentError(action, msg)
2657
2658 # TypeErrors or ValueErrors also indicate errors
2659 except (TypeError, ValueError):
2660 name = getattr(action.type, '__name__', repr(action.type))
2661 args = {'type': name, 'value': arg_string}
2662 msg = _('invalid %(type)s value: %(value)r')
2663 raise ArgumentError(action, msg % args)
2664
2665 # return the converted value
2666 return result
2667
2668 def _check_value(self, action, value):
2669 # converted value must be one of the choices (if specified)

Callers 2

_parse_known_argsMethod · 0.95
_get_valuesMethod · 0.95

Calls 7

callableFunction · 0.85
strFunction · 0.85
getattrFunction · 0.85
reprFunction · 0.85
_registry_getMethod · 0.80
ArgumentErrorClass · 0.70
_Function · 0.50

Tested by

no test coverage detected