diff --git a/blueprintcompiler/language/gobject_property.py b/blueprintcompiler/language/gobject_property.py index b267083..d896514 100644 --- a/blueprintcompiler/language/gobject_property.py +++ b/blueprintcompiler/language/gobject_property.py @@ -27,7 +27,9 @@ from .values import ArrayValue, ObjectValue, Value, VariantValue class Property(AstNode): grammar = Statement( - UseIdent("name"), ":", AnyOf(Binding, VariantValue, ObjectValue, Value, ArrayValue) + UseIdent("name"), + ":", + AnyOf(Binding, VariantValue, ObjectValue, Value, ArrayValue), ) @property diff --git a/blueprintcompiler/language/values.py b/blueprintcompiler/language/values.py index 41a4c5e..975dd95 100644 --- a/blueprintcompiler/language/values.py +++ b/blueprintcompiler/language/values.py @@ -371,16 +371,9 @@ class IdentLiteral(AstNode): else: return None + class VariantValue(AstNode): - grammar = [ - "variant", - "<", - UseQuoted("type"), - ">", - "(", - UseQuoted("value"), - ")" - ] + grammar = ["variant", "<", UseQuoted("type"), ">", "(", UseQuoted("value"), ")"] @property def var_type(self) -> str: @@ -404,12 +397,16 @@ class VariantValue(AstNode): raise CompileError(f"Cannot convert variant to number") elif isinstance(expected_type, gir.StringType): raise CompileError("Cannot convert variant to string") - elif isinstance(expected_type, gir.Boxed) and expected_type.full_name == "GLib.Variant": + elif ( + isinstance(expected_type, gir.Boxed) + and expected_type.full_name == "GLib.Variant" + ): pass else: raise CompileError(f"Cannot convert variant into {expected_type.full_name}") pass + class Literal(AstNode): grammar = AnyOf( TypeLiteral,