format with black

This commit is contained in:
jgcodes2020 2024-12-23 20:58:45 -05:00
parent 3efb2f9f4e
commit bc10ccee0c
2 changed files with 10 additions and 11 deletions

View file

@ -27,7 +27,9 @@ from .values import ArrayValue, ObjectValue, Value, VariantValue
class Property(AstNode): class Property(AstNode):
grammar = Statement( grammar = Statement(
UseIdent("name"), ":", AnyOf(Binding, VariantValue, ObjectValue, Value, ArrayValue) UseIdent("name"),
":",
AnyOf(Binding, VariantValue, ObjectValue, Value, ArrayValue),
) )
@property @property

View file

@ -371,16 +371,9 @@ class IdentLiteral(AstNode):
else: else:
return None return None
class VariantValue(AstNode): class VariantValue(AstNode):
grammar = [ grammar = ["variant", "<", UseQuoted("type"), ">", "(", UseQuoted("value"), ")"]
"variant",
"<",
UseQuoted("type"),
">",
"(",
UseQuoted("value"),
")"
]
@property @property
def var_type(self) -> str: def var_type(self) -> str:
@ -404,12 +397,16 @@ class VariantValue(AstNode):
raise CompileError(f"Cannot convert variant to number") raise CompileError(f"Cannot convert variant to number")
elif isinstance(expected_type, gir.StringType): elif isinstance(expected_type, gir.StringType):
raise CompileError("Cannot convert variant to string") 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 pass
else: else:
raise CompileError(f"Cannot convert variant into {expected_type.full_name}") raise CompileError(f"Cannot convert variant into {expected_type.full_name}")
pass pass
class Literal(AstNode): class Literal(AstNode):
grammar = AnyOf( grammar = AnyOf(
TypeLiteral, TypeLiteral,