Skip to content

Commit 4e68196

Browse files
[autofix.ci] apply automated fixes
1 parent 3a63b47 commit 4e68196

File tree

19 files changed

+114
-36
lines changed

19 files changed

+114
-36
lines changed

api/python/slint/interpreter.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -566,11 +566,7 @@ impl PyCallbackInfo {
566566
let arg_name = function.arg_names.get(idx).cloned();
567567
parameters.push(PyCallbackParameter::new(arg_name, arg_ty));
568568
}
569-
Self {
570-
name,
571-
parameters,
572-
return_type: type_to_python_hint(&function.return_type),
573-
}
569+
Self { name, parameters, return_type: type_to_python_hint(&function.return_type) }
574570
}
575571
}
576572

@@ -593,11 +589,7 @@ impl PyFunctionInfo {
593589
let arg_name = function.arg_names.get(idx).cloned();
594590
parameters.push(PyCallbackParameter::new(arg_name, arg_ty));
595591
}
596-
Self {
597-
name,
598-
parameters,
599-
return_type: type_to_python_hint(&function.return_type),
600-
}
592+
Self { name, parameters, return_type: type_to_python_hint(&function.return_type) }
601593
}
602594
}
603595

api/python/slint/pyproject.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ classifiers = [
2727
"Programming Language :: Python :: 3",
2828
"Programming Language :: Python :: 3.10",
2929
]
30-
dependencies = [
31-
"libcst>=1.8.5",
32-
]
30+
dependencies = ["libcst>=1.8.5"]
3331

3432
[project.urls]
3533
Homepage = "https://slint.dev"

api/python/slint/slint/__init__.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -418,20 +418,32 @@ def run_as_task(*args, **kwargs) -> None: # type: ignore
418418

419419
return callable
420420

421+
421422
_T_Callback = TypeVar("_T_Callback", bound=Callable[..., Any])
422423

424+
423425
@overload
424426
def callback(__func: _T_Callback, /) -> _T_Callback: ...
425427

428+
426429
@overload
427-
def callback(*, global_name: str | None = ..., name: str | None = ...) -> Callable[[ _T_Callback ], _T_Callback]: ...
430+
def callback(
431+
*, global_name: str | None = ..., name: str | None = ...
432+
) -> Callable[[_T_Callback], _T_Callback]: ...
433+
428434

429435
@overload
430-
def callback(__func: _T_Callback, /, *, global_name: str | None = ..., name: str | None = ...) -> _T_Callback: ...
436+
def callback(
437+
__func: _T_Callback, /, *, global_name: str | None = ..., name: str | None = ...
438+
) -> _T_Callback: ...
431439

432440

433441
def callback(
434-
__func: _T_Callback | None = None, /, *, global_name: str | None = None, name: str | None = None
442+
__func: _T_Callback | None = None,
443+
/,
444+
*,
445+
global_name: str | None = None,
446+
name: str | None = None,
435447
) -> typing.Union[_T_Callback, typing.Callable[[_T_Callback], _T_Callback]]:
436448
"""Use the callback decorator to mark a method as a callback that can be invoked from the Slint component.
437449

api/python/slint/slint/codegen/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Copyright © SixtyFPS GmbH <[email protected]>
2+
# SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
3+
14
from __future__ import annotations
25

36
from .cli import main

api/python/slint/slint/codegen/__main__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Copyright © SixtyFPS GmbH <[email protected]>
2+
# SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
3+
14
from __future__ import annotations
25

36
import sys

api/python/slint/slint/codegen/cli.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Copyright © SixtyFPS GmbH <[email protected]>
2+
# SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
3+
14
from __future__ import annotations
25

36
import argparse
@@ -10,9 +13,7 @@
1013
def build_parser() -> argparse.ArgumentParser:
1114
parser = argparse.ArgumentParser(
1215
prog="slint.codegen",
13-
description=(
14-
"Generate Python source and stub files from Slint .slint inputs."
15-
),
16+
description=("Generate Python source and stub files from Slint .slint inputs."),
1617
)
1718

1819
subparsers = parser.add_subparsers(dest="command", required=False)

api/python/slint/slint/codegen/emitters.py

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Copyright © SixtyFPS GmbH <[email protected]>
2+
# SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
3+
14
from __future__ import annotations
25

36
import os
@@ -53,7 +56,9 @@ def _stmt(code: str) -> cst.BaseStatement:
5356
library_expr_code = f"{{{', '.join(library_items)}}}" if library_items else "None"
5457

5558
style_expr = path_literal(config.style) if config.style else "None"
56-
domain_expr = path_literal(config.translation_domain) if config.translation_domain else "None"
59+
domain_expr = (
60+
path_literal(config.translation_domain) if config.translation_domain else "None"
61+
)
5762

5863
export_bindings: dict[str, str] = {}
5964
for component in artifacts.components:
@@ -68,7 +73,9 @@ def _stmt(code: str) -> cst.BaseStatement:
6873
]
6974

7075
header: list[cst.CSTNode] = [
71-
cst.EmptyLine(comment=cst.Comment(f"# Generated by slint.codegen from {source_relative}"))
76+
cst.EmptyLine(
77+
comment=cst.Comment(f"# Generated by slint.codegen from {source_relative}")
78+
)
7279
]
7380

7481
body: list[cst.CSTNode] = [
@@ -90,7 +97,11 @@ def _stmt(code: str) -> cst.BaseStatement:
9097
)
9198
body.append(
9299
cst.SimpleStatementLine(
93-
[cst.Assign(targets=[cst.AssignTarget(cst.Name("__all__"))], value=all_list)]
100+
[
101+
cst.Assign(
102+
targets=[cst.AssignTarget(cst.Name("__all__"))], value=all_list
103+
)
104+
]
94105
)
95106
)
96107
body.append(cst.EmptyLine())
@@ -112,7 +123,7 @@ def _stmt(code: str) -> cst.BaseStatement:
112123

113124
load_source = (
114125
"def _load() -> types.SimpleNamespace:\n"
115-
" \"\"\"Load the compiled Slint module for this package.\"\"\"\n"
126+
' """Load the compiled Slint module for this package."""\n'
116127
" package = __package__ or (__spec__.parent if __spec__ else None)\n"
117128
" if package:\n"
118129
" ctx = _resources.as_file(_resources.files(package).joinpath(_SLINT_RESOURCE))\n"
@@ -180,11 +191,17 @@ def register_type(type_str: str) -> None:
180191
]
181192
if export_names:
182193
all_list = cst.List(
183-
elements=[cst.Element(cst.SimpleString(repr(name))) for name in export_names]
194+
elements=[
195+
cst.Element(cst.SimpleString(repr(name))) for name in export_names
196+
]
184197
)
185198
post_body.append(
186199
cst.SimpleStatementLine(
187-
[cst.Assign(targets=[cst.AssignTarget(cst.Name("__all__"))], value=all_list)]
200+
[
201+
cst.Assign(
202+
targets=[cst.AssignTarget(cst.Name("__all__"))], value=all_list
203+
)
204+
]
188205
)
189206
)
190207
post_body.append(cst.EmptyLine())
@@ -194,7 +211,9 @@ def ann_assign(name: str, type_expr: str) -> cst.BaseStatement:
194211
[
195212
cst.AnnAssign(
196213
target=cst.Name(name),
197-
annotation=cst.Annotation(annotation=cst.parse_expression(type_expr)),
214+
annotation=cst.Annotation(
215+
annotation=cst.parse_expression(type_expr)
216+
),
198217
value=None,
199218
)
200219
]
@@ -253,7 +272,13 @@ def init_stub() -> cst.FunctionDef:
253272
post_body.append(
254273
cst.ClassDef(
255274
name=cst.Name(enum_meta.py_name),
256-
bases=[cst.Arg(value=cst.Attribute(value=cst.Name("enum"), attr=cst.Name("Enum")))],
275+
bases=[
276+
cst.Arg(
277+
value=cst.Attribute(
278+
value=cst.Name("enum"), attr=cst.Name("Enum")
279+
)
280+
)
281+
],
257282
body=cst.IndentedBlock(body=enum_body),
258283
)
259284
)
@@ -274,12 +299,16 @@ def init_stub() -> cst.FunctionDef:
274299
component_body.append(ann_assign(fn.py_name, annotation))
275300
for global_meta in component.globals:
276301
component_body.append(
277-
ann_assign(global_meta.py_name, f"{component.py_name}.{global_meta.py_name}")
302+
ann_assign(
303+
global_meta.py_name, f"{component.py_name}.{global_meta.py_name}"
304+
)
278305
)
279306

280307
for global_meta in component.globals:
281308
inner_body: list[cst.BaseStatement] = []
282-
if not (global_meta.properties or global_meta.callbacks or global_meta.functions):
309+
if not (
310+
global_meta.properties or global_meta.callbacks or global_meta.functions
311+
):
283312
inner_body.append(ellipsis_line())
284313
else:
285314
for prop in global_meta.properties:
@@ -306,7 +335,9 @@ def init_stub() -> cst.FunctionDef:
306335
name=cst.Name(component.py_name),
307336
bases=[
308337
cst.Arg(
309-
value=cst.Attribute(value=cst.Name("slint"), attr=cst.Name("Component"))
338+
value=cst.Attribute(
339+
value=cst.Name("slint"), attr=cst.Name("Component")
340+
)
310341
)
311342
],
312343
body=cst.IndentedBlock(body=component_body),

api/python/slint/slint/codegen/generator.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Copyright © SixtyFPS GmbH <[email protected]>
2+
# SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
3+
14
from __future__ import annotations
25

36
import shutil

api/python/slint/slint/codegen/models.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Copyright © SixtyFPS GmbH <[email protected]>
2+
# SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
3+
14
from __future__ import annotations
25

36
from dataclasses import dataclass

api/python/slint/slint/codegen/utils.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Copyright © SixtyFPS GmbH <[email protected]>
2+
# SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
3+
14
from __future__ import annotations
25

36
from pathlib import Path

0 commit comments

Comments
 (0)