Skip to content

Commit 3709269

Browse files
committed
style: formatage et nettoyage des imports dans le répertoire Core
1 parent c495d20 commit 3709269

23 files changed

Lines changed: 525 additions & 578 deletions

Core/AdvancedConfigEditor.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030

3131
import yaml
3232

33-
3433
# ---------------------------------------------------------------------------
3534
# Lecture / écriture de fichiers
3635
# ---------------------------------------------------------------------------
@@ -385,7 +384,9 @@ def validate_payload(file_id: str, data: Any) -> tuple[list[str], list[str]]:
385384
not isinstance(req_files, list)
386385
or not all(isinstance(item, str) for item in req_files)
387386
):
388-
errs.append("dependencies.requirements_files must be a list of strings.")
387+
errs.append(
388+
"dependencies.requirements_files must be a list of strings."
389+
)
389390
autogen = deps.get("auto_generate_from_imports")
390391
if autogen is not None and not isinstance(autogen, bool):
391392
errs.append(
@@ -469,7 +470,9 @@ def validate_payload(file_id: str, data: Any) -> tuple[list[str], list[str]]:
469470
return errs, warns
470471

471472

472-
def make_default_content(file_id: str, is_yaml: bool, workspace_dir: str | None = None) -> str:
473+
def make_default_content(
474+
file_id: str, is_yaml: bool, workspace_dir: str | None = None
475+
) -> str:
473476
"""Construire le contenu par défaut pour un type de fichier donné."""
474477
if file_id == "ark":
475478
try:
@@ -506,5 +509,3 @@ def make_default_content(file_id: str, is_yaml: bool, workspace_dir: str | None
506509
return yaml.safe_dump(payload, allow_unicode=True, sort_keys=False)
507510

508511
return "" if is_yaml else "{}\n"
509-
510-

Core/Auto_Command_Builder/__init__.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
from .auto_build import (
22
_default_builder_for_engine,
33
_detect_modules_preferring_requirements,
4-
compute_auto_for_engine,
5-
compute_for_all,
64
_is_stdlib_module,
75
_load_engine_package_mapping,
86
_load_mapping,
@@ -13,12 +11,14 @@
1311
_parse_requirements,
1412
_read_json_file,
1513
_scan_imports,
14+
_tr,
1615
_write_report_if_enabled,
17-
register_package_import_name,
18-
register_import_alias,
19-
register_auto_builder,
16+
compute_auto_for_engine,
17+
compute_for_all,
2018
register_aliases,
21-
_tr,
19+
register_auto_builder,
20+
register_import_alias,
21+
register_package_import_name,
2222
)
2323

2424
__all__ = [

Core/Auto_Command_Builder/auto_build.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import re
2222
from typing import Optional
2323

24-
from Ui.i18n import log_with_level, log_i18n_level
24+
from Ui.i18n import log_i18n_level, log_with_level
2525

2626
# Optional access to registered engines for discovery
2727
try:

Core/Compiler/__init__.py

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -23,38 +23,36 @@
2323

2424
from __future__ import annotations
2525

26-
# ============================================================================
27-
# IMPORTS LOCAUX - Core.Compiler
28-
# ============================================================================
29-
30-
from Core.Compiler.utils import (
31-
build_command,
32-
validate_command,
33-
escape_arguments,
34-
sanitize_path,
35-
CommandBuilder,
36-
detect_python_executable,
37-
get_interpreter_version,
38-
check_module_available,
26+
from Core.Compiler.engine_runner import (
27+
BuildContext,
28+
EngineRunnerError,
29+
resolve_engine_command,
30+
run_engine_compile,
31+
run_engine_compile_streaming,
3932
)
40-
4133
from Core.Compiler.process_killer import (
4234
ProcessInfo,
4335
ProcessKiller,
36+
get_process_info,
4437
kill_process,
4538
kill_process_tree,
46-
get_process_info,
4739
)
48-
49-
from Core.Compiler.engine_runner import (
50-
BuildContext,
51-
EngineRunnerError,
52-
resolve_engine_command,
53-
run_engine_compile,
54-
run_engine_compile_streaming,
40+
from Core.Compiler.utils import (
41+
CommandBuilder,
42+
build_command,
43+
check_module_available,
44+
detect_python_executable,
45+
escape_arguments,
46+
get_interpreter_version,
47+
sanitize_path,
48+
validate_command,
5549
)
50+
from Core.engine.registry import create, get_engine
51+
52+
# ============================================================================
53+
# IMPORTS LOCAUX - Core.Compiler
54+
# ============================================================================
5655

57-
from Core.engine.registry import get_engine, create
5856

5957
__all__ = [
6058
# utils.py

Core/Compiler/engine_runner.py

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,10 @@
3333
from pathlib import Path
3434
from typing import Any, Callable, Optional
3535

36-
from Core.process_security import hardened_popen_kwargs, secure_command
37-
3836
# BuildContext lives in engine_sdk; imported here so callers of this module
3937
# only need to import from Core.Compiler.
4038
from Core.engine.build_context import BuildContext
39+
from Core.process_security import hardened_popen_kwargs, secure_command
4140

4241

4342
class EngineRunnerError(RuntimeError):
@@ -66,11 +65,10 @@ def resolve_engine_command(
6665
"""
6766
try:
6867
import Core.engine as engines_loader
68+
6969
engine = engines_loader.create(engine_id)
7070
except Exception as exc:
71-
raise EngineRunnerError(
72-
f"Unable to load engine '{engine_id}': {exc}"
73-
) from exc
71+
raise EngineRunnerError(f"Unable to load engine '{engine_id}': {exc}") from exc
7472

7573
try:
7674
setattr(engine, "_config_overrides", dict(engine_config or {}))
@@ -92,7 +90,7 @@ def resolve_engine_command(
9290
raise EngineRunnerError(f"Engine '{engine_id}' returned no command")
9391

9492
program, args = resolved
95-
93+
9694
# Retrieve engine-specific environment
9795
try:
9896
env = engine.environment() if hasattr(engine, "environment") else {}
@@ -148,10 +146,10 @@ def _on_stderr(line: str):
148146

149147
result["stdout"] = "\n".join(captured_stdout)
150148
result["stderr"] = "\n".join(captured_stderr)
151-
149+
152150
if not result["success"] and not result.get("error"):
153151
result["error"] = result["stderr"].strip() or "Build failed"
154-
152+
155153
return result
156154

157155

@@ -188,11 +186,14 @@ def run_engine_compile_streaming(
188186
# ── 2. Resolve (program, args, env) from engine ──────────────────────────
189187
try:
190188
if on_stdout:
191-
on_stdout("🔨 Étape 1/3 : Vérification et installation des outils requis...")
192-
189+
on_stdout(
190+
"🔨 Étape 1/3 : Vérification et installation des outils requis..."
191+
)
192+
193193
import Core.engine as engines_loader
194+
194195
engine_instance = engines_loader.create(engine_id)
195-
196+
196197
# Ensure tools are installed (this may take time, so we do it in the thread)
197198
def _log(fr, en):
198199
if on_stdout:
@@ -202,21 +203,29 @@ def _log(fr, en):
202203
class LogBridge:
203204
def __init__(self, log_cb):
204205
self.log_cb = log_cb
205-
def tr(self, fr, en): return en # Simple fallback
206+
207+
def tr(self, fr, en):
208+
return en # Simple fallback
206209

207210
if hasattr(engine_instance, "ensure_tools_installed"):
208-
if not engine_instance.ensure_tools_installed(LogBridge(_log), stop_signal=stop_signal):
211+
if not engine_instance.ensure_tools_installed(
212+
LogBridge(_log), stop_signal=stop_signal
213+
):
209214
if stop_signal and stop_signal():
210215
return _failure("Compilation annulée par l'utilisateur.")
211-
return _failure(f"Échec de l'installation des outils pour '{engine_id}'")
216+
return _failure(
217+
f"Échec de l'installation des outils pour '{engine_id}'"
218+
)
212219

213220
if stop_signal and stop_signal():
214221
return _failure("Compilation annulée.")
215222

216223
if on_stdout:
217224
on_stdout("⚙️ Étape 2/3 : Génération de la commande de compilation...")
218225

219-
program, args, engine_env = resolve_engine_command(engine_id, context, engine_config)
226+
program, args, engine_env = resolve_engine_command(
227+
engine_id, context, engine_config
228+
)
220229
except EngineRunnerError as exc:
221230
return _failure(str(exc))
222231
except Exception as exc:
@@ -235,7 +244,7 @@ def tr(self, fr, en): return en # Simple fallback
235244

236245
# ── 4. Run with streaming ────────────────────────────────────────────────
237246
command = [safe_program] + safe_args
238-
247+
239248
if on_stdout:
240249
on_stdout(f"🚀 Étape 3/3 : Exécution du processus de compilation...")
241250
on_stdout(f" 💻 Commande : {' '.join(command)}")
@@ -267,16 +276,21 @@ def _read_stream(stream, callback):
267276
callback(line.rstrip())
268277
stream.close()
269278

270-
stdout_thread = threading.Thread(target=_read_stream, args=(process.stdout, on_stdout))
271-
stderr_thread = threading.Thread(target=_read_stream, args=(process.stderr, on_stderr))
272-
279+
stdout_thread = threading.Thread(
280+
target=_read_stream, args=(process.stdout, on_stdout)
281+
)
282+
stderr_thread = threading.Thread(
283+
target=_read_stream, args=(process.stderr, on_stderr)
284+
)
285+
273286
stdout_thread.start()
274287
stderr_thread.start()
275288

276289
try:
277290
while process.poll() is None:
278291
if stop_signal and stop_signal():
279292
from Core.Compiler.process_killer import kill_process_tree
293+
280294
kill_process_tree(process.pid)
281295
break
282296
time.sleep(0.05)
@@ -293,9 +307,9 @@ def _read_stream(stream, callback):
293307
}
294308

295309

296-
297310
# ── helpers ──────────────────────────────────────────────────────────────────
298311

312+
299313
def _failure(error: str) -> dict[str, Any]:
300314
return {
301315
"success": False,

Core/Compiler/process_killer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@
3030
from __future__ import annotations
3131

3232
import os
33-
import sys
3433
import signal
3534
import subprocess
35+
import sys
3636
import time
37-
from pathlib import Path
38-
from typing import Optional, List, Dict, Any
3937
from datetime import datetime
38+
from pathlib import Path
39+
from typing import Any, Dict, List, Optional
4040

4141
# Platform detection
4242
_IS_WINDOWS = sys.platform == "win32"

Core/Compiler/utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323
from __future__ import annotations
2424

2525
import os
26-
import sys
27-
import subprocess
28-
import shlex
2926
import re
30-
from typing import Optional, Dict, Any, List, Tuple
27+
import shlex
28+
import subprocess
29+
import sys
30+
from typing import Any, Dict, List, Optional, Tuple
3131

3232

3333
def build_command(

0 commit comments

Comments
 (0)