fix formatting and some tests

This commit is contained in:
jgcodes2020 2024-12-24 10:41:35 -05:00
parent c708532a8d
commit ab9d902cc5
4 changed files with 8 additions and 7 deletions

View file

@ -98,7 +98,7 @@ class MenuAttribute(AstNode):
return self.tokens["name"]
@property
def value(self) -> StringValue | VariantValue:
def value(self) -> T.Union[StringValue, VariantValue]:
if len(self.children[StringValue]) > 0:
return self.children[StringValue][0]
elif len(self.children[VariantValue]) > 0:

View file

@ -29,6 +29,7 @@ from .types import TypeName
from .variant import VarContent
import gi
gi.require_version("GLib", "2.0")
from gi.repository import GLib
@ -377,7 +378,6 @@ class IdentLiteral(AstNode):
return None
class VariantValue(AstNode):
grammar = [
"variant",
@ -424,7 +424,7 @@ class VariantValue(AstNode):
def validate_type(self):
if not GLib.VariantType.string_is_valid(self.var_type):
raise CompileError(f"`{self.var_type}` is not a valid variant type")
@validate()
def validate_content(self):
if not GLib.VariantType.string_is_valid(self.var_type):

View file

@ -8,7 +8,7 @@ from .contexts import ScopeCtx, ValueTypeCtx
from .gobject_object import Object
from .types import TypeName
VAR_CONTENT_HOOKS = []
VAR_CONTENT_HOOKS: list[T.Any] = []
class VarContent(AstNode):