Improve boolean input handling in console.py

Refactor boolean input handling to avoid eval and improve type checking.
pull/2486/head
CoderShady 1 day ago committed by GitHub
parent ccae640478
commit 5121d68574
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -102,7 +102,10 @@ def handle_input(
user_input = input("").strip()
if check_type is not False:
try:
isinstance(eval(user_input), check_type) # fixme: remove eval
if check_type is bool and isinstance(user_input, str):
if user_input.lower() in ['true', '1', 't', 'y', 'yes', 'yup']: return True
if user_input.lower() in ['false', '0', 'f', 'n', 'no', 'nope']: return False
raise ValueError
return check_type(user_input)
except:
console.print(

Loading…
Cancel
Save