summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlf Magnusson <ulfalizer@gmail.com>2018-07-17 05:02:00 +0200
committerUlf Magnusson <ulfalizer@gmail.com>2018-07-17 14:48:21 +0200
commitedffe870f25d2f594bc2dbc918db97bee5774efa (patch)
treec10c77b126cb0dce3a349050cbf185c011f3b002
parent1a3d08d0caa3cb481301bf8af819b16b76f96f76 (diff)
Factor out isinstance(str) check in set_value()
All types besides bool and tristate require the argument to be a string.
-rw-r--r--kconfiglib.py15
1 files 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(