Method: pylint.config._pylint_config.utils.should_retry_after_invalid_input
Calls: 2, Exceptions: 0, Paths: 1Back
Path 1: 2 calls (1.0)
get_and_validate_format def (1) validate_yes_no def (1)
should_retry_after_invalid_input.
1def should_retry_after_invalid_input(
2 func: Callable[_P, _ReturnValueT]
3) -> Callable[_P, _ReturnValueT]:
4 """Decorator that handles InvalidUserInput exceptions and retries."""
5
6 def inner_function(*args: _P.args, **kwargs: _P.kwargs) -> _ReturnValueT:
7 called_once = False
8 while True:
9 try:
10 return func(*args, **kwargs)
11 except InvalidUserInput as exc:
12 if called_once and exc.input == "exit()":
13 print("Stopping 'pylint-config'.")
14 sys.exit()
15 print(f"Answer should be one of {exc.valid}.")
16 print("Type 'exit()' if you want to exit the program.")
17 called_once = True
18
19 return inner_function