mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
Format using black
This commit is contained in:
parent
6a36d92380
commit
8fee46ec68
40 changed files with 975 additions and 610 deletions
|
@ -34,12 +34,16 @@ class Property(AstNode):
|
|||
UseIdent("bind_source"),
|
||||
".",
|
||||
UseIdent("bind_property"),
|
||||
ZeroOrMore(AnyOf(
|
||||
["no-sync-create", UseLiteral("no_sync_create", True)],
|
||||
["inverted", UseLiteral("inverted", True)],
|
||||
["bidirectional", UseLiteral("bidirectional", True)],
|
||||
Match("sync-create").warn("sync-create is deprecated in favor of no-sync-create"),
|
||||
)),
|
||||
ZeroOrMore(
|
||||
AnyOf(
|
||||
["no-sync-create", UseLiteral("no_sync_create", True)],
|
||||
["inverted", UseLiteral("inverted", True)],
|
||||
["bidirectional", UseLiteral("bidirectional", True)],
|
||||
Match("sync-create").warn(
|
||||
"sync-create is deprecated in favor of no-sync-create"
|
||||
),
|
||||
)
|
||||
),
|
||||
";",
|
||||
],
|
||||
Statement(
|
||||
|
@ -63,19 +67,16 @@ class Property(AstNode):
|
|||
def gir_class(self):
|
||||
return self.parent.parent.gir_class
|
||||
|
||||
|
||||
@property
|
||||
def gir_property(self):
|
||||
if self.gir_class is not None:
|
||||
return self.gir_class.properties.get(self.tokens["name"])
|
||||
|
||||
|
||||
@property
|
||||
def value_type(self):
|
||||
if self.gir_property is not None:
|
||||
return self.gir_property.type
|
||||
|
||||
|
||||
@validate("name")
|
||||
def property_exists(self):
|
||||
if self.gir_class is None:
|
||||
|
@ -91,15 +92,19 @@ class Property(AstNode):
|
|||
if self.gir_property is None:
|
||||
raise CompileError(
|
||||
f"Class {self.gir_class.full_name} does not contain a property called {self.tokens['name']}",
|
||||
did_you_mean=(self.tokens["name"], self.gir_class.properties.keys())
|
||||
did_you_mean=(self.tokens["name"], self.gir_class.properties.keys()),
|
||||
)
|
||||
|
||||
@validate("bind")
|
||||
def property_bindable(self):
|
||||
if self.tokens["bind"] and self.gir_property is not None and self.gir_property.construct_only:
|
||||
if (
|
||||
self.tokens["bind"]
|
||||
and self.gir_property is not None
|
||||
and self.gir_property.construct_only
|
||||
):
|
||||
raise CompileError(
|
||||
f"{self.gir_property.full_name} can't be bound because it is construct-only",
|
||||
hints=["construct-only properties may only be set to a static value"]
|
||||
hints=["construct-only properties may only be set to a static value"],
|
||||
)
|
||||
|
||||
@validate("name")
|
||||
|
@ -107,7 +112,6 @@ class Property(AstNode):
|
|||
if self.gir_property is not None and not self.gir_property.writable:
|
||||
raise CompileError(f"{self.gir_property.full_name} is not writable")
|
||||
|
||||
|
||||
@validate()
|
||||
def obj_property_type(self):
|
||||
if len(self.children[Object]) == 0:
|
||||
|
@ -115,20 +119,23 @@ class Property(AstNode):
|
|||
|
||||
object = self.children[Object][0]
|
||||
type = self.value_type
|
||||
if object and type and object.gir_class and not object.gir_class.assignable_to(type):
|
||||
if (
|
||||
object
|
||||
and type
|
||||
and object.gir_class
|
||||
and not object.gir_class.assignable_to(type)
|
||||
):
|
||||
raise CompileError(
|
||||
f"Cannot assign {object.gir_class.full_name} to {type.full_name}"
|
||||
)
|
||||
|
||||
|
||||
@validate("name")
|
||||
def unique_in_parent(self):
|
||||
self.validate_unique_in_parent(
|
||||
f"Duplicate property '{self.tokens['name']}'",
|
||||
check=lambda child: child.tokens["name"] == self.tokens["name"]
|
||||
check=lambda child: child.tokens["name"] == self.tokens["name"],
|
||||
)
|
||||
|
||||
|
||||
@docs("name")
|
||||
def property_docs(self):
|
||||
if self.gir_property is not None:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue