Skip to content

Commit 3d3b0ca

Browse files
committed
style: formatage et nettoyage des imports dans le répertoire Ui
1 parent 3709269 commit 3d3b0ca

23 files changed

Lines changed: 998 additions & 387 deletions

Ui/Cli/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,3 @@
44
from .entrypoint import main
55

66
__all__ = ["build_cli", "has_click", "main"]
7-

Ui/Cli/app.py

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
from pathlib import Path
66
from typing import Any
77

8-
from .runtime import install_runtime, should_enable_qt
9-
108
from .helpers import (
119
CliSpecError,
1210
build_context_object_from_ark_config,
@@ -32,6 +30,7 @@
3230
validate_ark_config,
3331
write_lock_files,
3432
)
33+
from .runtime import install_runtime, should_enable_qt
3534

3635
try:
3736
import click # type: ignore
@@ -88,6 +87,7 @@ def _build_impl(
8887

8988
# 1. BCASL Pre-compile check (Point 1 of mutation plan)
9089
from .helpers import run_bcasl_before_compile_sync
90+
9191
if not run_bcasl_before_compile_sync(workspace):
9292
return 1
9393

@@ -97,7 +97,9 @@ def _build_impl(
9797
engine_id = engine_override or str(validated.config["build"]["engine"])
9898
_ensure_engine_known(engine_id)
9999
# Point 3 alignment: build_lock_payload now correctly loads engine config via fixed path
100-
lock_payload = build_lock_payload(workspace, validated.config, engine_id=engine_id)
100+
lock_payload = build_lock_payload(
101+
workspace, validated.config, engine_id=engine_id
102+
)
101103
lock_paths = write_lock_files(workspace, lock_payload)
102104
context = build_context_object_from_ark_config(validated.config)
103105
result = run_engine_compile(
@@ -162,7 +164,9 @@ def _build_impl(
162164
current_config = load_ark_config(workspace)
163165
validated = validate_ark_config(workspace, current_config)
164166
regenerated = build_lock_payload(
165-
workspace, validated.config, engine_id=str(validated.config["build"]["engine"])
167+
workspace,
168+
validated.config,
169+
engine_id=str(validated.config["build"]["engine"]),
166170
)
167171
rebuild_cache = cache_rebuild_lock(workspace, regenerated)
168172
comparison = compare_lock_payloads(lock_payload, regenerated)
@@ -212,7 +216,9 @@ def cli():
212216
@click.option("--install-requirements", is_flag=True)
213217
@click.option("--generate-requirements", is_flag=True)
214218
@click.option("--json", "as_json", is_flag=True)
215-
def init_cmd(entry, icon, with_venv, install_requirements, generate_requirements, as_json):
219+
def init_cmd(
220+
entry, icon, with_venv, install_requirements, generate_requirements, as_json
221+
):
216222
"""Initialize the current directory as an ARK workspace."""
217223
try:
218224
payload = init_workspace(
@@ -249,7 +255,9 @@ def init_cmd(entry, icon, with_venv, install_requirements, generate_requirements
249255
@click.option("--json", "as_json", is_flag=True)
250256
def build_cmd(engine_override, lock_file, lock_arg, as_json):
251257
"""Build from ark.yml or rebuild from a lock file."""
252-
effective_lock = lock_arg if lock_arg and lock_file == "__default__" else lock_file
258+
effective_lock = (
259+
lock_arg if lock_arg and lock_file == "__default__" else lock_file
260+
)
253261
try:
254262
code = _build_impl(
255263
workspace=Path.cwd(),
@@ -309,6 +317,7 @@ def unset_group():
309317
"dev-engine-dir",
310318
"dev-plugin-dir",
311319
):
320+
312321
def _make_set(spec_key: str):
313322
@set_group.command(spec_key)
314323
@click.argument("path")
@@ -369,7 +378,9 @@ def scaffold_engine_cmd(name, root_dir, as_json):
369378
_echo_json(payload)
370379
return
371380
if not payload.get("created"):
372-
raise click.ClickException(payload.get("reason", "Unable to create scaffold"))
381+
raise click.ClickException(
382+
payload.get("reason", "Unable to create scaffold")
383+
)
373384
click.echo(payload["path"])
374385

375386
@scaffold_group.command("plugin-bcasl")
@@ -382,7 +393,9 @@ def scaffold_plugin_cmd(name, root_dir, as_json):
382393
_echo_json(payload)
383394
return
384395
if not payload.get("created"):
385-
raise click.ClickException(payload.get("reason", "Unable to create scaffold"))
396+
raise click.ClickException(
397+
payload.get("reason", "Unable to create scaffold")
398+
)
386399
click.echo(payload["path"])
387400

388401
return cli

Ui/Cli/discovery.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ def scaffold_engine(target_name: str, root_dir: str | None = None) -> dict[str,
249249
"",
250250
"@engine_register",
251251
f"class {safe.title().replace('_', '')}Engine(CompilerEngine):",
252-
f' id = \"{safe}\"',
252+
f' id = "{safe}"',
253253
f" name = \"{safe.title().replace('_', ' ')}\"",
254254
' version = "0.1.0"',
255255
' required_core_version = "1.0.0"',

Ui/Cli/helpers.py

Lines changed: 41 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,38 +7,36 @@
77
from pathlib import Path
88
from typing import Any
99

10-
from Core.Configs import (
11-
ArkConfigError,
12-
ArkConfigValidationResult,
13-
load_ark_config as _load_ark_config,
14-
new_workspace_config,
15-
validate_ark_config as _validate_ark_config,
16-
write_ark_config,
17-
)
18-
from Core.Locking import (
19-
BuildContext,
20-
build_context_from_ark_config as _build_context_from_ark_config,
21-
build_context_from_lock as _build_context_from_lock,
22-
build_lock_payload as _build_lock_payload,
23-
cache_rebuild_lock as _cache_rebuild_lock,
24-
compare_lock_payloads as _compare_lock_payloads,
25-
default_lock_path as _default_lock_path,
26-
ensure_workspace_layout,
27-
load_yaml_file,
28-
write_lock_files as _write_lock_files,
29-
)
3010
from Core.Compiler.engine_runner import run_engine_compile as _core_run_engine_compile
3111
from Core.Configs import (
3212
CONFIG_KEYS,
3313
DEFAULT_USER_DIRS,
14+
ArkConfigError,
15+
ArkConfigValidationResult,
3416
UserConfigError,
35-
config_home as _config_home,
36-
ensure_config_home as _ensure_config_home,
37-
config_file_for as _config_file_for,
17+
)
18+
from Core.Configs import config_file_for as _config_file_for
19+
from Core.Configs import config_home as _config_home
20+
from Core.Configs import ensure_config_home as _ensure_config_home
21+
from Core.Configs import load_ark_config as _load_ark_config
22+
from Core.Configs import (
23+
new_workspace_config,
3824
resolve_config_value,
3925
set_config_value,
4026
unset_config_value,
4127
)
28+
from Core.Configs import validate_ark_config as _validate_ark_config
29+
from Core.Configs import write_ark_config
30+
from Core.Locking import BuildContext
31+
from Core.Locking import build_context_from_ark_config as _build_context_from_ark_config
32+
from Core.Locking import build_context_from_lock as _build_context_from_lock
33+
from Core.Locking import build_lock_payload as _build_lock_payload
34+
from Core.Locking import cache_rebuild_lock as _cache_rebuild_lock
35+
from Core.Locking import compare_lock_payloads as _compare_lock_payloads
36+
from Core.Locking import default_lock_path as _default_lock_path
37+
from Core.Locking import ensure_workspace_layout, load_yaml_file
38+
from Core.Locking import write_lock_files as _write_lock_files
39+
4240
from .discovery import (
4341
bcasl_list_payload,
4442
engine_info_payload,
@@ -63,6 +61,7 @@ class ArkValidationResult:
6361
# resolve_config_value / set_config_value / unset_config_value are imported
6462
# directly from Core.Configs above and re-exported as-is.
6563

64+
6665
def config_home() -> Path:
6766
"""Return the ARK user config root (delegates to Core.Configs)."""
6867
return _config_home()
@@ -162,7 +161,9 @@ def init_workspace(
162161
text=True,
163162
)
164163
if result.returncode != 0:
165-
raise CliSpecError(result.stderr.strip() or "requirements installation failed")
164+
raise CliSpecError(
165+
result.stderr.strip() or "requirements installation failed"
166+
)
166167

167168
return {
168169
"workspace": str(workspace),
@@ -204,7 +205,12 @@ def validate_ark_config(workspace: Path, config: dict[str, Any]) -> ArkValidatio
204205
def engine_version(engine_id: str) -> str:
205206
try:
206207
payload = engine_info_payload(engine_id)
207-
return str(((payload.get("engine") or {}) if payload.get("found") else {}).get("version") or "unknown")
208+
return str(
209+
((payload.get("engine") or {}) if payload.get("found") else {}).get(
210+
"version"
211+
)
212+
or "unknown"
213+
)
208214
except Exception:
209215
return "unknown"
210216

@@ -301,16 +307,19 @@ def run_bcasl_before_compile_sync(workspace: Path) -> bool:
301307
Returns:
302308
True if compilation can proceed (success or BCASL disabled), False otherwise.
303309
"""
304-
from .output import info, error, success, log
305310
from bcasl.Loader import run_pre_compile
306311

312+
from .output import error, info, log, success
313+
307314
class CliBcaslHost:
308315
def __init__(self, ws_dir: Path):
309316
self.workspace_dir = str(ws_dir)
317+
310318
class Logger:
311319
def append(self, msg: str):
312320
# Strip trailing newline as our log() adds one
313321
log("BCASL", msg.rstrip())
322+
314323
self.log = Logger()
315324

316325
host = CliBcaslHost(workspace)
@@ -337,25 +346,28 @@ def append(self, msg: str):
337346

338347
def run_bcasl_headless(args: list[str]) -> int:
339348
"""Run BCASL in headless mode for the current workspace."""
340-
from .output import error, success
341349
from bcasl.Loader import run_pre_compile
342350

351+
from .output import error, success
352+
343353
workspace = Path.cwd()
344354
if "run" in args:
345355
# If workspace path is provided in args, use it
346356
for i, arg in enumerate(args):
347357
if arg == "run" and i + 1 < len(args):
348-
candidate = Path(args[i+1])
358+
candidate = Path(args[i + 1])
349359
if candidate.is_dir():
350360
workspace = candidate.resolve()
351361
break
352362

353363
class CliBcaslHost:
354364
def __init__(self, ws_dir: Path):
355365
self.workspace_dir = str(ws_dir)
366+
356367
class Logger:
357368
def append(self, msg: str):
358369
print(msg, end="", flush=True)
370+
359371
self.log = Logger()
360372

361373
host = CliBcaslHost(workspace)
@@ -370,6 +382,7 @@ def append(self, msg: str):
370382
error(f"BCASL failed: {exc}")
371383
return 1
372384

385+
373386
def launch_gui(*, legacy: bool = False) -> int:
374387
return launch_main_application(
375388
no_splash=False,

Ui/Cli/icons.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,3 @@ def set_window_icon(target) -> None:
3636
target.setWindowIcon(QIcon(icon_path))
3737
except Exception:
3838
pass
39-

Ui/Cli/launchers.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,12 @@ def launch_main_application(
5757
no_splash: bool = False, ide_gui: bool = False, classic_gui: bool = False
5858
) -> int:
5959
try:
60-
from Ui.Gui.Gui import PyCompilerArkGui
6160
from PySide6.QtCore import Qt, QTimer
6261
from PySide6.QtGui import QColor, QPixmap
6362
from PySide6.QtWidgets import QSplashScreen
6463

64+
from Ui.Gui.Gui import PyCompilerArkGui
65+
6566
app = _get_or_create_qapp()
6667
set_app_icon(app)
6768
app_version = _get_app_version()
@@ -88,24 +89,27 @@ def launch_main_application(
8889
screen = app.primaryScreen()
8990
if screen:
9091
sgeo = screen.availableGeometry()
91-
max_w, max_h = int(sgeo.width() * 0.5), int(sgeo.height() * 0.5)
92+
max_w, max_h = int(sgeo.width() * 0.5), int(
93+
sgeo.height() * 0.5
94+
)
9295
if pix.width() > max_w or pix.height() > max_h:
9396
pix = pix.scaled(
94-
max_w, max_h,
97+
max_w,
98+
max_h,
9599
Qt.KeepAspectRatio,
96-
Qt.SmoothTransformation
100+
Qt.SmoothTransformation,
97101
)
98102

99103
splash = QSplashScreen(pix, Qt.WindowStaysOnTopHint)
100-
104+
101105
# Centrage explicite
102106
if screen:
103107
sgeo = screen.availableGeometry()
104108
splash.move(
105109
sgeo.x() + (sgeo.width() - pix.width()) // 2,
106-
sgeo.y() + (sgeo.height() - pix.height()) // 2
110+
sgeo.y() + (sgeo.height() - pix.height()) // 2,
107111
)
108-
112+
109113
splash.show()
110114
app.processEvents()
111115
break
@@ -151,4 +155,3 @@ def _launch_main():
151155
except Exception as exc:
152156
error(f"Failed to launch main application: {exc}")
153157
return 1
154-

Ui/Cli/output.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,3 @@ def error(message: str) -> None:
6060

6161
def success(message: str) -> None:
6262
log("SUCCESS", message, err=False)
63-

Ui/Cli/runtime.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,4 +246,3 @@ def install_runtime(app_version: str, enable_qt: bool = True) -> None:
246246
install_qt_metadata(app_version)
247247
install_qt_handlers()
248248
install_signal_handlers()
249-

0 commit comments

Comments
 (0)