You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, invalid attributes (such as integers) gets raised during rendering, not when constructing the element, leading to cryptic stack traces.
The error should be raised directly when constructing the invalid element, not during render:
>>> el = div(a=1)
>>> print(el)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/andreas/code/htpy/htpy/__init__.py", line 272, in __str__
return _Markup("".join(str(x) for x in self))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/andreas/code/htpy/htpy/__init__.py", line 272, in <genexpr>
return _Markup("".join(str(x) for x in self))
^^^^^^^^^^^^^^^^^^^^^^
File "/Users/andreas/code/htpy/htpy/__init__.py", line 331, in _iter_context
yield f"<{self._name}{_attrs_string(self._attrs)}>"
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/andreas/code/htpy/htpy/__init__.py", line 112, in _attrs_string
result = " ".join(k if v is True else f'{k}="{v}"' for k, v in _generate_attrs(attrs))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/andreas/code/htpy/htpy/__init__.py", line 112, in <genexpr>
result = " ".join(k if v is True else f'{k}="{v}"' for k, v in _generate_attrs(attrs))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/andreas/code/htpy/htpy/__init__.py", line 106, in _generate_attrs
raise ValueError(f"Attribute value must be a string , got {value!r}")
ValueError: Attribute value must be a string , got 1
The text was updated successfully, but these errors were encountered:
This commit transforms attributes to strings directly when being called
rather at rendering time. This makes exceptions for invalid attributes
appear directly leading to clearer stack traces.
Fixes#49.
This commit transforms attributes to strings directly when being called
rather at rendering time. This makes exceptions for invalid attributes
appear directly leading to clearer stack traces.
Fixes#49.
Currently, invalid attributes (such as integers) gets raised during rendering, not when constructing the element, leading to cryptic stack traces.
The error should be raised directly when constructing the invalid element, not during render:
The text was updated successfully, but these errors were encountered: