From 59f9502240c7f7b860cf6ed4cc4b642c5ac13744 Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Fri, 4 Sep 2026 06:45:58 +0200 Subject: [PATCH] fix: install black's transitive deps in the pyodide code formatter (#29503) Saving any tool or function in the admin UI threw "ModuleNotFoundError: No module named 'click'" in the browser, even on a fresh tool with no custom code, because the click name never appears in user code at all. The in-browser formatter runs black through a Pyodide/micropip worker. black needs click, mypy_extensions, pathspec, platformdirs and pytokens at import time, but the vendored pyodide-lock.json records none of these as black's dependencies, and micropip only walks a locked package's declared deps when install() is given explicit constraints, which this worker never does. So only black itself ever got installed. Requesting the five packages explicitly alongside black fixes it without touching the worker or the lock file. --- src/lib/components/common/CodeEditor.svelte | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/lib/components/common/CodeEditor.svelte b/src/lib/components/common/CodeEditor.svelte index a9078d8b21..64073e3a45 100644 --- a/src/lib/components/common/CodeEditor.svelte +++ b/src/lib/components/common/CodeEditor.svelte @@ -122,7 +122,15 @@ print(black.format_str("""${code.replace(/\\/g, '\\\\').replace(/`/g, '\\`').rep print("${endTag}") `; - const packages = ['black']; + // black's pyodide-lock entry declares no dependencies, so micropip installs none of them + const packages = [ + 'black', + 'click', + 'mypy_extensions', + 'pathspec', + 'platformdirs', + 'pytokens' + ]; function handleMessage(event) { const { id: eventId, stdout, stderr } = event.data;