From 500ad8b00f371b6530c5a6780051db28efb51142 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 13 Jun 2017 14:49:15 +0200 Subject: [PATCH] Use strings for Perc configtypes --- qutebrowser/config/configtypes.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/qutebrowser/config/configtypes.py b/qutebrowser/config/configtypes.py index e90b31911..c876b64f3 100644 --- a/qutebrowser/config/configtypes.py +++ b/qutebrowser/config/configtypes.py @@ -549,24 +549,19 @@ class Perc(_Numeric): """A percentage, as a string ending with %.""" - def from_str(self, value): + def from_py(self, value): + self._basic_validation(value, pytype=str) if not value: return None - elif not value.endswith('%'): - raise configexc.ValidationError(value, "does not end with %") + if not value.endswith('%'): + raise configexc.ValidationError(value, "does not end with %") try: floatval = float(value[:-1]) except ValueError: raise configexc.ValidationError(value, "must be a percentage!") - return self.from_py(floatval) - - def from_py(self, value): - self._basic_validation(value, pytype=float) - if not value: - return None - self._validate_bounds(value, suffix='%') - return value + self._validate_bounds(floatval, suffix='%') + return floatval class PercOrInt(_Numeric):