Skip to content

Commit ebccd9a

Browse files
author
PyCompiler ARK++ Team
committed
fix: update pre-commit configuration and resolve bandit dependency issue
- Add pbr dependency to bandit pre-commit hook - Clean and reinstall pre-commit environment - Ensure all quality tools work correctly
1 parent 0881ec9 commit ebccd9a

61 files changed

Lines changed: 4589 additions & 2628 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,4 @@ ci:
5454
autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate'
5555
autoupdate_schedule: weekly
5656
skip: []
57-
submodules: false
57+
submodules: false

.pref/pycompiler_gui_prefs.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
"language_pref": "System",
33
"language": "System",
44
"theme": "Techno"
5-
}
5+
}

.pref/system_preferences.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
"system_language_code": "fr",
55
"system_language_name": "Fran\u00e7ais",
66
"system_theme": "dark"
7-
}
7+
}

API/Hash Report/__init__.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
- Uses API_SDK.ACASL_SDK facade and wrap_post_context
1212
"""
1313

14-
from API_SDK.ACASL_SDK import wrap_post_context
15-
from pathlib import Path
1614
import hashlib
1715
import json
18-
from typing import List
16+
from pathlib import Path
17+
18+
from API_SDK.ACASL_SDK import wrap_post_context
1919

2020
ACASL_PLUGIN = True # required explicit signature for ACASL packages
2121
# Metadata (required id/description; optional name/version)
@@ -32,16 +32,16 @@
3232

3333
def _sha256(path: Path) -> str:
3434
h = hashlib.sha256()
35-
with open(path, 'rb') as f:
36-
for chunk in iter(lambda: f.read(8192), b''):
35+
with open(path, "rb") as f:
36+
for chunk in iter(lambda: f.read(8192), b""):
3737
h.update(chunk)
3838
return h.hexdigest()
3939

4040

4141
def acasl_run(ctx) -> None:
4242
"""Compute SHA‑256 for produced artifacts and write a JSON report next to them."""
4343
sctx = wrap_post_context(ctx)
44-
arts: List[str] = list(getattr(sctx, 'artifacts', []) or [])
44+
arts: list[str] = list(getattr(sctx, "artifacts", []) or [])
4545
if not arts:
4646
sctx.log_warn("ACASL/hash_report: no artifacts.")
4747
return
@@ -64,13 +64,7 @@ def acasl_run(ctx) -> None:
6464
try:
6565
out.write_text(json.dumps({"artifacts": rows}, indent=2, ensure_ascii=False), encoding="utf-8")
6666
# Bilingual info
67-
sctx.msg_info(
68-
"ACASL — Hachage | Hash",
69-
(
70-
f"Rapport de hachage écrit: {out}\n\n"
71-
f"Hash report written: {out}"
72-
)
73-
)
67+
sctx.msg_info("ACASL — Hachage | Hash", (f"Rapport de hachage écrit: {out}\n\n" f"Hash report written: {out}"))
7468
sctx.log_info(f"ACASL/hash_report: written {out}")
7569
except Exception as e:
7670
sctx.log_error(f"ACASL/hash_report: failed writing {out}: {e}")

API/cleaner/__init__.py

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
# SPDX-License-Identifier: GPL-3.0-only
22
# Copyright (C) 2025 Samuel Amen Ague
33
# Author: Samuel Amen Ague
4-
from API_SDK import PluginBase, PreCompileContext, wrap_context, plugin
5-
import shutil
6-
import os
4+
import asyncio
75
import fnmatch
8-
from API_SDK import PluginMeta
9-
from API_SDK import load_plugin_translations
6+
import os
7+
import shutil
8+
109
import API_SDK
11-
import asyncio
10+
from API_SDK import PluginBase, PluginMeta, PreCompileContext, load_plugin_translations, plugin, wrap_context
1211

1312
# BCASL package signature (required)
1413
BCASL_PLUGIN = True
@@ -18,9 +17,9 @@
1817
BCASL_VERSION = "1.0.0"
1918
BCASL_AUTHOR = "Samuel Amen Ague"
2019
BCASL_CREATED = "2025-09-06"
21-
BCASL_COMPATIBILITY = ['PyCompiler ARK++ v3.2+', 'Python 3.10+']
20+
BCASL_COMPATIBILITY = ["PyCompiler ARK++ v3.2+", "Python 3.10+"]
2221
BCASL_LICENSE = "GPL-3.0-only"
23-
BCASL_TAGS = ['pre-compilation', 'clean', 'cache', 'pyc']
22+
BCASL_TAGS = ["pre-compilation", "clean", "cache", "pyc"]
2423

2524

2625
@plugin(id="cleaner", version="1.0.0", description="Nettoie le workspace (.pyc et __pycache__)")
@@ -35,7 +34,7 @@ def on_pre_compile(self, ctx: PreCompileContext) -> None:
3534

3635
# Préparer exclusions (globales + spécifiques au plugin)
3736
cfg = sctx.config_view
38-
subcfg = cfg.for_plugin(getattr(self, 'id', 'cleaner'))
37+
subcfg = cfg.for_plugin(getattr(self, "id", "cleaner"))
3938
lang_code = subcfg.get("language", "System")
4039
tr = asyncio.run(load_plugin_translations(__file__, lang_code))
4140
exclude = list(cfg.exclude_patterns) + list(subcfg.get("exclude_patterns", []))
@@ -69,7 +68,12 @@ def _is_excluded(path_str: str) -> bool:
6968
return
7069

7170
# 1) Analyse (comptage des éléments à supprimer) avec progression indéterminée
72-
ph = API_SDK.progress(tr.get("progress_title", "Nettoyage du workspace"), tr.get("analysis_text", "Analyse des éléments à supprimer..."), maximum=0, cancelable=True)
71+
ph = API_SDK.progress(
72+
tr.get("progress_title", "Nettoyage du workspace"),
73+
tr.get("analysis_text", "Analyse des éléments à supprimer..."),
74+
maximum=0,
75+
cancelable=True,
76+
)
7377
try:
7478
total = 0
7579
for r, dirs, files in os.walk(root, topdown=False):
@@ -133,10 +137,13 @@ def _is_excluded(path_str: str) -> bool:
133137
ph.update(current, f"Suppression __pycache__ ({current}/{total})")
134138

135139
# 3) Logs UI
136-
sctx.log_info(f"🗑️ Nettoyage terminé : {pyc_count} fichier(s) .pyc et {pycache_count} dossier(s) __pycache__ supprimés.")
140+
sctx.log_info(
141+
f"🗑️ Nettoyage terminé : {pyc_count} fichier(s) .pyc et {pycache_count} dossier(s) __pycache__ supprimés."
142+
)
137143
finally:
138144
ph.close()
139145

146+
140147
# Métadonnées et instance du plugin pour BCASL
141148
META = PluginMeta(
142149
id=BCASL_ID,
@@ -148,5 +155,6 @@ def _is_excluded(path_str: str) -> bool:
148155

149156
# Fonction requise par le chargeur BCASL
150157

158+
151159
def bcasl_register(manager):
152160
manager.add_plugin(PLUGIN)

API/compress_zip/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919
- Idempotent: does not overwrite unless explicitly allowed (we don't overwrite by default).
2020
"""
2121

22-
import os
23-
import sys
2422
import stat
23+
import sys
2524
import zipfile
2625
from pathlib import Path
27-
from typing import List, Optional, Tuple
26+
from typing import Optional
27+
2828
from API_SDK.ACASL_SDK import wrap_post_context
2929

3030
ACASL_PLUGIN = True
@@ -49,7 +49,7 @@ def _is_executable_file(p: Path) -> bool:
4949
return False
5050

5151

52-
def _pick_target(artifacts: List[Path]) -> Optional[Path]:
52+
def _pick_target(artifacts: list[Path]) -> Optional[Path]:
5353
"""Pick the most plausible main target among artifacts.
5454
5555
Priority:
@@ -138,7 +138,7 @@ def acasl_run(ctx) -> None:
138138
return
139139

140140
# Decide whether to zip a directory or a single file
141-
to_zip: Tuple[str, str] # (kind, path)
141+
to_zip: tuple[str, str] # (kind, path)
142142
kind = "dir" if target.is_dir() else "file"
143143

144144
# For PyInstaller-like one-folder layouts: if the target is an executable file and its parent

API/header_injector/__init__.py

Lines changed: 44 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Author: Samuel Amen Ague
44
from __future__ import annotations
55

6-
from API_SDK import PluginBase, PreCompileContext, wrap_context, plugin, PluginMeta
6+
from API_SDK import PluginBase, PluginMeta, PreCompileContext, plugin, wrap_context
77

88
# BCASL package signature (required)
99
BCASL_PLUGIN = True
@@ -13,14 +13,15 @@
1313
BCASL_VERSION = "1.1.0"
1414
BCASL_AUTHOR = "Samuel Amen Ague"
1515
BCASL_CREATED = "2025-09-06"
16-
BCASL_COMPATIBILITY = ['PyCompiler ARK++ v3.2+', 'Python 3.10+']
16+
BCASL_COMPATIBILITY = ["PyCompiler ARK++ v3.2+", "Python 3.10+"]
1717
BCASL_LICENSE = "GPL-3.0-only"
18-
BCASL_TAGS = ['pre-compilation', 'license', 'SPDX']
18+
BCASL_TAGS = ["pre-compilation", "license", "SPDX"]
1919

20-
import API_SDK
21-
from pathlib import Path
22-
from typing import List, Optional, Tuple
2320
import re
21+
from pathlib import Path
22+
from typing import Optional
23+
24+
import API_SDK
2425

2526
# Détection et normalisation de la licence du workspace
2627
try:
@@ -32,7 +33,7 @@
3233
_tomllib = None
3334

3435

35-
def _normalize_spdx(lic: str) -> Tuple[str, str]:
36+
def _normalize_spdx(lic: str) -> tuple[str, str]:
3637
s = (lic or "").strip()
3738
if not s:
3839
return "", ""
@@ -115,9 +116,13 @@ def _detect_license_from_pyproject(root: Path) -> Optional[str]:
115116
def _detect_license_from_files(root: Path) -> Optional[str]:
116117
try:
117118
candidates = [
118-
"LICENSE", "LICENSE.txt", "LICENSE.md",
119-
"LICENCE", "LICENCE.txt",
120-
"COPYING", "COPYING.txt",
119+
"LICENSE",
120+
"LICENSE.txt",
121+
"LICENSE.md",
122+
"LICENCE",
123+
"LICENCE.txt",
124+
"COPYING",
125+
"COPYING.txt",
121126
]
122127
for name in candidates:
123128
p = root / name
@@ -131,7 +136,7 @@ def _detect_license_from_files(root: Path) -> Optional[str]:
131136
return None
132137

133138

134-
def _detect_workspace_license(root: Path) -> Tuple[str, str]:
139+
def _detect_workspace_license(root: Path) -> tuple[str, str]:
135140
lic = _detect_license_from_pyproject(root) or _detect_license_from_files(root)
136141
if not lic:
137142
return "", ""
@@ -141,12 +146,14 @@ def _detect_workspace_license(root: Path) -> Tuple[str, str]:
141146

142147
# Détection SPDX déjà présente
143148

149+
144150
def _has_spdx(text: str) -> bool:
145151
return "SPDX-License-Identifier:" in text
146152

147153

148154
# Injection d'une ligne SPDX minimale selon le type de fichier
149155

156+
150157
def _inject_license_for_file(path: Path, text: str, spdx_id: str) -> str:
151158
"""Injecte une ligne SPDX minimale selon le type de fichier, sans en-tête additionnel.
152159
- .py: insère '# SPDX-License-Identifier: <ID>' après shebang/encodage
@@ -183,7 +190,11 @@ def _inject_license_for_file(path: Path, text: str, spdx_id: str) -> str:
183190
return text
184191

185192

186-
@plugin(id="license_injector", version="1.1.0", description="Injecte une ligne de licence (SPDX) en tête des fichiers ciblés")
193+
@plugin(
194+
id="license_injector",
195+
version="1.1.0",
196+
description="Injecte une ligne de licence (SPDX) en tête des fichiers ciblés",
197+
)
187198
class LicenseInjector(PluginBase):
188199
def on_pre_compile(self, ctx: PreCompileContext) -> None:
189200
try:
@@ -193,31 +204,37 @@ def on_pre_compile(self, ctx: PreCompileContext) -> None:
193204
return
194205

195206
cfg = sctx.config_view
196-
subcfg = cfg.for_plugin(getattr(self, 'id', 'license_injector'))
207+
subcfg = cfg.for_plugin(getattr(self, "id", "license_injector"))
197208

198209
# Déterminer la licence du workspace
199210
spdx_id, lic_name = _detect_workspace_license(sctx.workspace_root)
200211
if not spdx_id:
201-
sctx.log_info("license_injector: aucune licence détectée dans le workspace (pyproject/LICEN[SC]E/COPYING). Aucune injection.")
212+
sctx.log_info(
213+
"license_injector: aucune licence détectée dans le workspace (pyproject/LICEN[SC]E/COPYING). Aucune injection."
214+
)
202215
return
203216

204217
# Cibles et exclusions
205-
patterns: List[str] = subcfg.get("file_patterns", []) or cfg.file_patterns or ["**/*.py", "**/*.md"]
206-
exclude: List[str] = list(cfg.exclude_patterns) + list(subcfg.get("exclude_patterns", []))
218+
patterns: list[str] = subcfg.get("file_patterns", []) or cfg.file_patterns or ["**/*.py", "**/*.md"]
219+
exclude: list[str] = list(cfg.exclude_patterns) + list(subcfg.get("exclude_patterns", []))
207220
# Exclusions communes
208221
for pat in ("venv/**", ".git/**", "main.build/**"):
209222
if pat not in exclude:
210223
exclude.append(pat)
211224

212225
# Demande confirmation
213-
if not sctx.msg_question("License Injector", f"Injecter la licence (SPDX: {spdx_id}) dans les fichiers correspondant aux motifs: {patterns}?", default_yes=False):
226+
if not sctx.msg_question(
227+
"License Injector",
228+
f"Injecter la licence (SPDX: {spdx_id}) dans les fichiers correspondant aux motifs: {patterns}?",
229+
default_yes=False,
230+
):
214231
sctx.log_warn("license_injector: opération annulée par l'utilisateur")
215232
return
216233

217234
# Phase 1: analyse des cibles
218235
ph = API_SDK.progress("Injection de licence", "Analyse des fichiers cibles...", maximum=0, cancelable=True)
219236
try:
220-
to_modify: List[Path] = []
237+
to_modify: list[Path] = []
221238
found = 0
222239
skipped_dup = 0
223240
for p in sctx.iter_files(patterns, exclude=exclude, enforce_workspace=True):
@@ -228,7 +245,9 @@ def on_pre_compile(self, ctx: PreCompileContext) -> None:
228245
try:
229246
text = p.read_text(encoding="utf-8", errors="ignore")
230247
except Exception as e:
231-
sctx.log_warn(f"Lecture échouée pour {p.relative_to(sctx.workspace_root) if p.exists() else p}: {e}")
248+
sctx.log_warn(
249+
f"Lecture échouée pour {p.relative_to(sctx.workspace_root) if p.exists() else p}: {e}"
250+
)
232251
continue
233252
if _has_spdx(text):
234253
skipped_dup += 1
@@ -245,7 +264,9 @@ def on_pre_compile(self, ctx: PreCompileContext) -> None:
245264
if found == 0:
246265
sctx.log_info("license_injector: aucun fichier cible")
247266
else:
248-
sctx.log_info(f"license_injector: aucun fichier à modifier (déj�� avec SPDX={skipped_dup}, total scannés={found})")
267+
sctx.log_info(
268+
f"license_injector: aucun fichier à modifier (déj�� avec SPDX={skipped_dup}, total scannés={found})"
269+
)
249270
return
250271

251272
# Phase 2: injection
@@ -270,7 +291,9 @@ def on_pre_compile(self, ctx: PreCompileContext) -> None:
270291
except Exception as e:
271292
sctx.log_warn(f"Écriture échouée pour {rel}: {e}")
272293

273-
sctx.log_info(f"license_injector: terminé. Modifiés={changed}, déjà avec SPDX={skipped_dup}, total scannés={found}")
294+
sctx.log_info(
295+
f"license_injector: terminé. Modifiés={changed}, déjà avec SPDX={skipped_dup}, total scannés={found}"
296+
)
274297
finally:
275298
ph.close()
276299

0 commit comments

Comments
 (0)