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

@ -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"]