From c68325476166a093d6583b34c18d77746df5a769 Mon Sep 17 00:00:00 2001 From: Giovanni Santini Date: Tue, 1 Aug 2023 11:55:33 +0200 Subject: [PATCH 1/2] fix: Make `command` required This solves a weird issue where the help function is executed everytime even when we specify a command. Fixes #122. --- blueprintcompiler/main.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/blueprintcompiler/main.py b/blueprintcompiler/main.py index 306dd7d..f3fbd7f 100644 --- a/blueprintcompiler/main.py +++ b/blueprintcompiler/main.py @@ -38,8 +38,7 @@ LIBDIR = None class BlueprintApp: def main(self): self.parser = argparse.ArgumentParser() - self.subparsers = self.parser.add_subparsers(metavar="command") - self.parser.set_defaults(func=self.cmd_help) + self.subparsers = self.parser.add_subparsers(metavar="command", required=True) compile = self.add_subcommand( "compile", "Compile blueprint files", self.cmd_compile From 5c7fb03da79abd9dc691675f4b83a33fe770f091 Mon Sep 17 00:00:00 2001 From: James Westman Date: Wed, 7 May 2025 17:08:26 -0500 Subject: [PATCH 2/2] Fix incorrect error with Adw.AlertDialog responses --- blueprintcompiler/language/contexts.py | 10 ++++++---- tests/samples/issue_195.blp | 11 +++++++++++ tests/samples/issue_195.ui | 16 ++++++++++++++++ 3 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 tests/samples/issue_195.blp create mode 100644 tests/samples/issue_195.ui diff --git a/blueprintcompiler/language/contexts.py b/blueprintcompiler/language/contexts.py index 6e26048..9376211 100644 --- a/blueprintcompiler/language/contexts.py +++ b/blueprintcompiler/language/contexts.py @@ -60,19 +60,21 @@ class ScopeCtx: passed = {} for obj in self._iter_recursive(self.node): - if obj.tokens["id"] is None: + from .gtk_menu import Menu + + if not (isinstance(obj, Object) or isinstance(obj, Menu)) or obj.id is None: continue - if obj.tokens["id"] in passed: + if obj.id in passed: token = obj.group.tokens["id"] if not isinstance(obj, Template) and not isinstance( obj, ExtListItemFactory ): raise CompileError( - f"Duplicate object ID '{obj.tokens['id']}'", + f"Duplicate object ID '{obj.id}'", token.range, ) - passed[obj.tokens["id"]] = obj + passed[obj.id] = obj def _iter_recursive(self, node: AstNode): yield node diff --git a/tests/samples/issue_195.blp b/tests/samples/issue_195.blp new file mode 100644 index 0000000..50b5b95 --- /dev/null +++ b/tests/samples/issue_195.blp @@ -0,0 +1,11 @@ +using Gtk 4.0; +using Adw 1; + +Adw.AlertDialog dialog1 { + responses [ + ok: "Ok", + cancel: "Cancel", + ] +} + +Button cancel {} diff --git a/tests/samples/issue_195.ui b/tests/samples/issue_195.ui new file mode 100644 index 0000000..b57a379 --- /dev/null +++ b/tests/samples/issue_195.ui @@ -0,0 +1,16 @@ + + + + + + + Ok + Cancel + + + + \ No newline at end of file