From edffe870f25d2f594bc2dbc918db97bee5774efa Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Tue, 17 Jul 2018 05:02:00 +0200 Subject: Factor out isinstance(str) check in set_value() All types besides bool and tristate require the argument to be a string. --- kconfiglib.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/kconfiglib.py b/kconfiglib.py index dc688f4..2306d46 100644 --- a/kconfiglib.py +++ b/kconfiglib.py @@ -3549,14 +3549,13 @@ class Symbol(object): return True # Check if the value is valid for our type - if not ((self.orig_type == BOOL and value in (0, 2, "n", "y") ) or - (self.orig_type == TRISTATE and value in (0, 1, 2, "n", "m", "y")) or - (self.orig_type == STRING and isinstance(value, str) ) or - (self.orig_type == INT and isinstance(value, str) - and _is_base_n(value, 10) ) or - (self.orig_type == HEX and isinstance(value, str) - and _is_base_n(value, 16) - and int(value, 16) >= 0)): + if not (self.orig_type == BOOL and value in (0, 2, "n", "y") or + self.orig_type == TRISTATE and value in (0, 1, 2, "n", "m", "y") or + (isinstance(value, str) and + (self.orig_type == STRING or + self.orig_type == INT and _is_base_n(value, 10) or + self.orig_type == HEX and _is_base_n(value, 16) + and int(value, 16) >= 0))): # Display tristate values as n, m, y in the warning self.kconfig._warn( -- cgit v1.2.3