Format using black

This commit is contained in:
James Westman 2022-12-19 11:49:10 -06:00
parent 6a36d92380
commit 8fee46ec68
No known key found for this signature in database
GPG key ID: CE2DBA0ADB654EA6
40 changed files with 975 additions and 610 deletions

View file

@ -27,16 +27,19 @@ from .common import *
class UI(AstNode):
""" The AST node for the entire file """
"""The AST node for the entire file"""
grammar = [
GtkDirective,
ZeroOrMore(Import),
Until(AnyOf(
Template,
menu,
Object,
), Eof()),
Until(
AnyOf(
Template,
menu,
Object,
),
Eof(),
),
]
@property
@ -61,11 +64,13 @@ class UI(AstNode):
return gir_ctx
@property
def objects_by_id(self):
return { obj.tokens["id"]: obj for obj in self.iterate_children_recursive() if obj.tokens["id"] is not None }
return {
obj.tokens["id"]: obj
for obj in self.iterate_children_recursive()
if obj.tokens["id"] is not None
}
@validate()
def gir_errors(self):
@ -74,7 +79,6 @@ class UI(AstNode):
if len(self._gir_errors):
raise MultipleErrors(self._gir_errors)
@validate()
def unique_ids(self):
passed = {}
@ -84,5 +88,7 @@ class UI(AstNode):
if obj.tokens["id"] in passed:
token = obj.group.tokens["id"]
raise CompileError(f"Duplicate object ID '{obj.tokens['id']}'", token.start, token.end)
raise CompileError(
f"Duplicate object ID '{obj.tokens['id']}'", token.start, token.end
)
passed[obj.tokens["id"]] = obj