From a79c139aa4fd070701ac883ba2143c3eacfe3064 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Wed, 19 Aug 2015 20:48:19 +0200 Subject: [PATCH] Revert "style: Check for QColor when setting in ColorDict." This reverts commit 9b82fae6fb3cf72a38219617d8e788e2b3eff6cf. --- qutebrowser/config/style.py | 16 +++++----------- tests/unit/config/test_style.py | 3 ++- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/qutebrowser/config/style.py b/qutebrowser/config/style.py index 50b6e9e8b..2b109e72b 100644 --- a/qutebrowser/config/style.py +++ b/qutebrowser/config/style.py @@ -73,17 +73,6 @@ class ColorDict(collections.UserDict): """A dict aimed at Qt stylesheet colors.""" - def __setitem__(self, key, val): - """Override __setitem__ to make sure no QColors are set. - - This could happen when accidentally declaring something as QtColor - instead of Color in the config, and it'd go unnoticed as the CSS is - invalid then. - """ - if isinstance(val, QColor): - raise TypeError("QColor passed to ColorDict!") - self.data[key] = val - def __getitem__(self, key): """Override dict __getitem__. @@ -104,6 +93,11 @@ class ColorDict(collections.UserDict): except KeyError: log.config.exception("No color defined for {}!".format(key)) return '' + if isinstance(val, QColor): + # This could happen when accidentally declaring something as + # QtColor instead of Color in the config, and it'd go unnoticed as + # the CSS is invalid then. + raise TypeError("QColor passed to ColorDict!") if 'fg' in key.split('.'): return 'color: {};'.format(val) elif 'bg' in key.split('.'): diff --git a/tests/unit/config/test_style.py b/tests/unit/config/test_style.py index f0cf44581..4f4041089 100644 --- a/tests/unit/config/test_style.py +++ b/tests/unit/config/test_style.py @@ -102,8 +102,9 @@ class TestColorDict: def test_qcolor(self): d = style.ColorDict() + d['foo'] = QColor() with pytest.raises(TypeError): - d['foo'] = QColor() + d['foo'] @pytest.mark.parametrize('key, expected', [