diff options
author | Eevee (Alex Munroe) <eevee.git@veekun.com> | 2013-08-16 18:02:27 -0700 |
---|---|---|
committer | Eevee (Alex Munroe) <eevee.git@veekun.com> | 2013-08-16 18:02:36 -0700 |
commit | 5b8758934a62b54dd571ef7c9d1f18037e0e69ac (patch) | |
tree | 715a004c7c695664c364f77752e67e1a33a5311b | |
parent | 27523a3752ff418fcc1dcd32960696ca5f364e05 (diff) | |
download | pyscss-5b8758934a62b54dd571ef7c9d1f18037e0e69ac.tar.gz |
Explode loudly when a Python type makes it into Sass-land.
-rw-r--r-- | scss/rule.py | 5 | ||||
-rw-r--r-- | scss/types.py | 16 |
2 files changed, 13 insertions, 8 deletions
diff --git a/scss/rule.py b/scss/rule.py index ea54873..8f84c9b 100644 --- a/scss/rule.py +++ b/scss/rule.py @@ -5,6 +5,7 @@ import six import logging from scss.cssdefs import _has_placeholder_re +from scss.types import Value log = logging.getLogger(__name__) @@ -88,8 +89,8 @@ class Namespace(object): def set_variable(self, name, value): name = normalize_var(name) - assert not (isinstance(value, six.string_types) and value.startswith('$')) - #assert isinstance(value, Value) + if not isinstance(value, Value): + raise TypeError("Expected a Sass type, got %r" % (item,)) self._variables[name] = value def _get_callable(self, chainmap, name, arity): diff --git a/scss/types.py b/scss/types.py index 40aa595..4a1cf50 100644 --- a/scss/types.py +++ b/scss/types.py @@ -453,14 +453,18 @@ class List(Value): sass_type_name = u'list' - def __init__(self, tokens, separator=None, use_comma=None): - if isinstance(tokens, List): - tokens = tokens.value + def __init__(self, iterable, separator=None, use_comma=None): + if isinstance(iterable, List): + iterable = iterable.value - if not isinstance(tokens, (list, tuple)): - raise TypeError("Expected list, got %r" % (tokens,)) + if not isinstance(iterable, (list, tuple)): + raise TypeError("Expected list, got %r" % (iterable,)) - self.value = list(tokens) + self.value = list(iterable) + + for item in self.value: + if not isinstance(item, Value): + raise TypeError("Expected a Sass type, got %r" % (item,)) # TODO remove separator argument entirely if use_comma is None: |