Revert "style: Check for QColor when setting in ColorDict."

This reverts commit 9b82fae6fb.
This commit is contained in:
Florian Bruhin 2015-08-19 20:48:19 +02:00
parent 1d5cae3146
commit a79c139aa4
2 changed files with 7 additions and 12 deletions

View File

@ -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('.'):

View File

@ -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', [