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
|
@ -26,21 +26,13 @@ from .common import *
|
|||
class ResponseId(AstNode):
|
||||
"""Response ID of action widget."""
|
||||
|
||||
ALLOWED_PARENTS: T.List[T.Tuple[str, str]] = [
|
||||
("Gtk", "Dialog"),
|
||||
("Gtk", "InfoBar")
|
||||
]
|
||||
ALLOWED_PARENTS: T.List[T.Tuple[str, str]] = [("Gtk", "Dialog"), ("Gtk", "InfoBar")]
|
||||
|
||||
grammar = [
|
||||
Keyword("response"),
|
||||
"=",
|
||||
AnyOf(
|
||||
UseIdent("response_id"),
|
||||
UseNumber("response_id")
|
||||
),
|
||||
Optional([
|
||||
Keyword("default"), UseLiteral("is_default", True)
|
||||
])
|
||||
AnyOf(UseIdent("response_id"), UseNumber("response_id")),
|
||||
Optional([Keyword("default"), UseLiteral("is_default", True)]),
|
||||
]
|
||||
|
||||
@validate()
|
||||
|
@ -91,18 +83,15 @@ class ResponseId(AstNode):
|
|||
|
||||
if isinstance(response, int):
|
||||
if response < 0:
|
||||
raise CompileError(
|
||||
"Numeric response type can't be negative")
|
||||
raise CompileError("Numeric response type can't be negative")
|
||||
elif isinstance(response, float):
|
||||
raise CompileError(
|
||||
"Response type must be GtkResponseType member or integer,"
|
||||
" not float"
|
||||
"Response type must be GtkResponseType member or integer," " not float"
|
||||
)
|
||||
else:
|
||||
responses = gir.get_type("ResponseType", "Gtk").members.keys()
|
||||
if response not in responses:
|
||||
raise CompileError(
|
||||
f"Response type \"{response}\" doesn't exist")
|
||||
raise CompileError(f'Response type "{response}" doesn\'t exist')
|
||||
|
||||
@validate("default")
|
||||
def no_multiple_default(self) -> None:
|
||||
|
@ -135,4 +124,3 @@ class ResponseId(AstNode):
|
|||
|
||||
_object: Object = self.parent.children[Object][0]
|
||||
return _object.tokens["id"]
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue