mirror of
https://github.com/esphome/esphome.git
synced 2026-10-06 02:51:29 +00:00
Miscellaneous Fixes
This commit is contained in:
@@ -134,7 +134,7 @@ class StructInitializer(Expression):
|
||||
class ArrayInitializer(Expression):
|
||||
def __init__(self, *args, **kwargs): # type: (*Any, **Any) -> None
|
||||
super(ArrayInitializer, self).__init__()
|
||||
self.multiline = kwargs.get('multiline', True)
|
||||
self.multiline = kwargs.get('multiline', False)
|
||||
self.args = []
|
||||
for arg in args:
|
||||
if arg is None:
|
||||
@@ -264,7 +264,8 @@ class FloatLiteral(Literal):
|
||||
|
||||
|
||||
# pylint: disable=bad-continuation
|
||||
def safe_exp(obj # type: Union[Expression, bool, str, unicode, int, long, float, TimePeriod]
|
||||
def safe_exp(
|
||||
obj # type: Union[Expression, bool, str, unicode, int, long, float, TimePeriod, list]
|
||||
):
|
||||
# type: (...) -> Expression
|
||||
if isinstance(obj, Expression):
|
||||
@@ -285,6 +286,8 @@ def safe_exp(obj # type: Union[Expression, bool, str, unicode, int, long, float
|
||||
return IntLiteral(int(obj.total_milliseconds))
|
||||
if isinstance(obj, TimePeriodSeconds):
|
||||
return IntLiteral(int(obj.total_seconds))
|
||||
if isinstance(obj, (tuple, list)):
|
||||
return ArrayInitializer(*[safe_exp(o) for o in obj])
|
||||
raise ValueError(u"Object is not an expression", obj)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user