Skip to content

Commit 30b2473

Browse files
committed
style: formatage et cohérence des imports dans les modules bcasl, engines et SDK
1 parent 3d3b0ca commit 30b2473

16 files changed

Lines changed: 100 additions & 87 deletions

File tree

Loaders/EngineLoader/loader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
import sys
2424
from types import ModuleType
2525

26-
from Core.engine.base import CompilerEngine
2726
from Core.engine import registry as engine_registry
27+
from Core.engine.base import CompilerEngine
2828

2929
logger = logging.getLogger(__name__)
3030

Plugins/Cleaner/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
# limitations under the License.
1515

1616
import os
17-
from pathlib import Path
1817
import shutil
18+
from pathlib import Path
1919
from typing import Optional
2020

2121
from bcasl import bc_register
@@ -24,8 +24,8 @@
2424
Dialog,
2525
get_language_code,
2626
load_plugin_language_file,
27-
register_plugin_translations,
2827
register_i18n_handler,
28+
register_plugin_translations,
2929
translate,
3030
)
3131

@@ -103,14 +103,14 @@ def _get_config(self, ctx: PreCompileContext) -> dict:
103103
def build_config_tab(self, parent, ctx: PreCompileContext, config: dict):
104104
try:
105105
from PySide6.QtWidgets import (
106-
QWidget,
107-
QVBoxLayout,
108106
QCheckBox,
109-
QGroupBox,
110107
QFormLayout,
108+
QGroupBox,
111109
QHBoxLayout,
112110
QLabel,
113111
QSizePolicy,
112+
QVBoxLayout,
113+
QWidget,
114114
)
115115
except Exception:
116116
return None

Plugins_SDK/BcPluginContext/Context.py

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -30,36 +30,22 @@
3030
import urllib.request
3131
from dataclasses import dataclass, field
3232
from pathlib import Path
33-
from typing import (
34-
Any,
35-
Optional,
36-
Union,
37-
List,
38-
Iterator,
39-
Dict,
40-
Set,
41-
Tuple,
42-
Pattern,
43-
)
33+
from typing import Any, Dict, Iterator, List, Optional, Pattern, Set, Tuple, Union
4434

4535
# -----------------------------
4636
# Plugin base (BCASL) and decorator
4737
# -----------------------------
4838
# Reuse BCASL types to guarantee compatibility with the host
4939
try: # noqa: E402
50-
from bcasl import (
51-
BCASL as BCASL,
52-
ExecutionReport as ExecutionReport,
53-
BcPluginBase as BcPluginBase,
54-
PluginMeta as PluginMeta,
55-
PreCompileContext as PreCompileContext,
56-
)
40+
from bcasl import BCASL as BCASL
41+
from bcasl import BcPluginBase as BcPluginBase
42+
from bcasl import ExecutionReport as ExecutionReport
43+
from bcasl import PluginMeta as PluginMeta
44+
from bcasl import PreCompileContext as PreCompileContext
5745

5846
try:
59-
from bcasl import (
60-
BCASL_PLUGIN_REGISTER_FUNC as BCASL_PLUGIN_REGISTER_FUNC,
61-
register_plugin as register_plugin,
62-
)
47+
from bcasl import BCASL_PLUGIN_REGISTER_FUNC as BCASL_PLUGIN_REGISTER_FUNC
48+
from bcasl import register_plugin as register_plugin
6349
except Exception: # pragma: no cover
6450

6551
def register_plugin(cls: Any) -> Any: # type: ignore
@@ -288,7 +274,9 @@ def set_selected_workspace(path: Pathish) -> bool:
288274
pass
289275
# Try to inform the GUI when running with UI; ignore result and accept by contract
290276
try:
291-
from Services.AdvancedAuth import request_workspace_change_from_BcPlugin # type: ignore
277+
from Services.AdvancedAuth import (
278+
request_workspace_change_from_BcPlugin,
279+
) # type: ignore
292280

293281
try:
294282
request_workspace_change_from_BcPlugin(str(path))

Plugins_SDK/GeneralContext/Dialog.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,21 @@
1818
import inspect
1919
from pathlib import Path
2020
from typing import Optional
21+
2122
import colorama
2223
from rich.console import Console
23-
from .i18n import translate
2424

2525
# Import des classes et fonctions de Core.dialogs
2626
from Ui.Gui.WidgetsCreator import (
27-
show_msgbox,
28-
sys_msgbox_for_installing,
29-
ProgressDialog,
3027
InstallAuth,
28+
ProgressDialog,
3129
_redact_secrets,
30+
show_msgbox,
31+
sys_msgbox_for_installing,
3232
)
3333

34+
from .i18n import translate
35+
3436

3537
class Dialog:
3638
"""Dialog class for plugins - uses Core.dialogs classes for all UI operations."""

Plugins_SDK/GeneralContext/i18n.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515

1616
from __future__ import annotations
1717

18-
from typing import Any, Optional, Callable
19-
import os
2018
import json
19+
import os
20+
from typing import Any, Callable, Optional
2121

2222
_GLOBAL_TR: dict[str, Any] = {}
2323
_GLOBAL_LANG: str = "en"

bcasl/Base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,7 @@ def _create_plugin_instance() -> "BcPluginBase":
800800

801801
# Appliquer la priorité basée sur les tags si pas explicitement définie
802802
if priority is None and plugin_instance is not None:
803-
from .tagging import TAG_PRIORITY_MAP, DEFAULT_TAG_PRIORITY
803+
from .tagging import DEFAULT_TAG_PRIORITY, TAG_PRIORITY_MAP
804804

805805
tags = getattr(plugin_instance.meta, "tags", ()) or ()
806806
if tags:

bcasl/Loader.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,18 @@
3131
import os
3232
from pathlib import Path
3333
from typing import Any, Optional
34+
3435
import yaml
3536

3637
from Core.Configs import load_ark_config
37-
from .executor import BCASL
3838

3939
from .Base import BcPluginBase, PreCompileContext
40+
from .executor import BCASL
4041
from .tagging import compute_tag_order
4142

4243
# Qt (facultatif). Ne pas importer QtWidgets au niveau module pour compatibilité headless.
4344
try: # pragma: no cover
44-
from PySide6.QtCore import QObject, QThread, Signal, Slot, Qt
45+
from PySide6.QtCore import QObject, Qt, QThread, Signal, Slot
4546
except Exception: # pragma: no cover
4647
QObject = None # type: ignore
4748
QThread = None # type: ignore
@@ -602,7 +603,10 @@ def open_bc_loader_dialog(self) -> None:
602603
plugin_instances = _discover_bcasl_plugins(Plugins_dir, workspace_root, cfg)
603604

604605
from Ui.Gui.Dialogs.BcaslDialog import open_bcasl_pipeline_dialog
605-
open_bcasl_pipeline_dialog(self, workspace_root, meta_map, cfg, plugin_instances)
606+
607+
open_bcasl_pipeline_dialog(
608+
self, workspace_root, meta_map, cfg, plugin_instances
609+
)
606610

607611
except Exception as e:
608612
try:
@@ -653,7 +657,7 @@ def run_pre_compile_async(self, on_done: Optional[callable] = None) -> None:
653657
return
654658

655659
if QThread is not None and QObject is not None and Signal is not None:
656-
from Ui.Gui.Dialogs.BcaslDialog import _BCASLWorker, _BCASLUiBridge
660+
from Ui.Gui.Dialogs.BcaslDialog import _BCASLUiBridge, _BCASLWorker
657661

658662
thread = QThread()
659663
worker = _BCASLWorker(workspace_root, Plugins_dir, cfg, plugin_timeout)
@@ -730,9 +734,7 @@ def run_pre_compile(self) -> Optional[object]:
730734
if not _is_bcasl_enabled(workspace_root):
731735
try:
732736
if hasattr(self, "log") and self.log is not None:
733-
self.log.append(
734-
"BCASL désactivé dans ark.yml. Exécution ignorée\n"
735-
)
737+
self.log.append("BCASL désactivé dans ark.yml. Exécution ignorée\n")
736738
except Exception:
737739
pass
738740
return None

bcasl/__init__.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,17 @@
2929

3030
from __future__ import annotations
3131

32-
from .executor import BCASL
33-
3432
# Coeur BCASL (moteur de plugins et contexte)
3533
from .Base import (
36-
ExecutionReport,
34+
BCASL_PLUGIN_REGISTER_FUNC,
3735
BcPluginBase,
36+
ExecutionReport,
3837
PluginMeta,
3938
PreCompileContext,
4039
bc_register,
4140
register_plugin,
42-
BCASL_PLUGIN_REGISTER_FUNC,
4341
)
42+
from .executor import BCASL
4443

4544
# Chargeur (exécution asynchrone, UI, annulation, configuration)
4645
from .Loader import (
@@ -55,8 +54,8 @@
5554
from .validator import (
5655
CompatibilityCheckResult,
5756
check_plugin_compatibility,
58-
validate_plugins_compatibility,
5957
print_compatibility_report,
58+
validate_plugins_compatibility,
6059
)
6160

6261
__version__ = "1.0.0"

bcasl/executor.py

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,10 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16-
from .Base import (
17-
BCASL_PLUGIN_REGISTER_FUNC,
18-
_PluginRecord,
19-
BcPluginBase,
20-
ExecutionItem,
21-
ExecutionReport,
22-
PluginMeta,
23-
PreCompileContext,
24-
_logger,
25-
)
26-
2716
import heapq
2817
import importlib.util
29-
import multiprocessing as mp
3018
import math
19+
import multiprocessing as mp
3120
import os
3221
import signal
3322
import subprocess
@@ -37,6 +26,17 @@
3726
from pathlib import Path
3827
from typing import Any, Optional
3928

29+
from .Base import (
30+
BCASL_PLUGIN_REGISTER_FUNC,
31+
BcPluginBase,
32+
ExecutionItem,
33+
ExecutionReport,
34+
PluginMeta,
35+
PreCompileContext,
36+
_logger,
37+
_PluginRecord,
38+
)
39+
4040
_ACTIVE_WORKER_PIDS: set[int] = set()
4141
_ACTIVE_WORKER_LOCK = threading.Lock()
4242

@@ -121,7 +121,7 @@ def _normalize_tags(tags: Any) -> list[str]:
121121
def _tag_priority_from_tags(tags: Any) -> int:
122122
"""Calcule la priorité basée sur les tags."""
123123
try:
124-
from .tagging import TAG_PRIORITY_MAP, DEFAULT_TAG_PRIORITY
124+
from .tagging import DEFAULT_TAG_PRIORITY, TAG_PRIORITY_MAP
125125

126126
norm = _normalize_tags(tags)
127127
if not norm:
@@ -902,7 +902,7 @@ def run_pre_compile(
902902
continue
903903

904904
_logger.info("--- Phase: %s ---", pname)
905-
905+
906906
# Sous-ensemble d'items pour cette phase
907907
p_items = {pid: active_items[pid] for pid in p_ids}
908908
indeg, children = _build_dependency_graph(p_items)
@@ -914,24 +914,39 @@ def run_pre_compile(
914914
for pid in order:
915915
rec = p_items[pid]
916916
if skip_dependents_on_failure:
917-
failed_dep = next((d for d in rec.requires if d in failed_seq), None)
917+
failed_dep = next(
918+
(d for d in rec.requires if d in failed_seq), None
919+
)
918920
if failed_dep:
919-
_record_dependency_blocked(report, plugin_id=pid, name=rec.plugin.meta.name, failed_dep=str(failed_dep))
921+
_record_dependency_blocked(
922+
report,
923+
plugin_id=pid,
924+
name=rec.plugin.meta.name,
925+
failed_dep=str(failed_dep),
926+
)
920927
failed_seq.add(pid)
921928
continue
922-
923-
# Note: On respecte toujours le mode sandbox (processus isolé) si activé,
929+
930+
# Note: On respecte toujours le mode sandbox (processus isolé) si activé,
924931
# mais on lance les plugins l'un après l'autre.
925-
ok = _run_plugin_sequential(report, rec, ctx, self.project_root, self.plugin_timeout_s, eff_sandbox, stop_requested)
932+
ok = _run_plugin_sequential(
933+
report,
934+
rec,
935+
ctx,
936+
self.project_root,
937+
self.plugin_timeout_s,
938+
eff_sandbox,
939+
stop_requested,
940+
)
926941
if not ok:
927942
failed_seq.add(pid)
928-
if fail_fast: return report
943+
if fail_fast:
944+
return report
929945

930946
_logger.info(report.summary())
931947
return report
932948

933949

934-
935950
def _plugin_worker(
936951
module_path: str, plugin_id: str, project_root: str, config: dict[str, Any], q
937952
) -> None:

bcasl/validator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626

2727
from __future__ import annotations
2828

29-
from typing import Tuple, List
3029
from dataclasses import dataclass
30+
from typing import List, Tuple
3131

3232

3333
@dataclass

0 commit comments

Comments
 (0)