[Enhancement] Python (Pyodide) playground: Black or equivalent Formatter for Monaco #37

Closed
opened 2026-04-28 23:48:47 +00:00 by spikerj · 1 comment
Owner

Summary

Provide Python code formatting once Monaco Format document piping exists for the playground — browser-friendly constraint (Pyodide) vs server-backed formatter.

Options to evaluate — pick implementation time

A. Run Black (or autopep8) inside Pyodide worker if WASM port available and deps acceptable.
B. Backend / code-execution microservice: format user snippet with black (or Ruff --format), return text — aligns with graded runs already leaving the sandbox.
C. Lighter PEP8-only heuristic (last resort — not parity with “Black”).

Integration

  • Implement provideDocumentFormattingEditProvider('python', …) (or our Monaco language id).
  • Latency UX: spinner / cancel for slow WASM cold start.
  • Teaching: deterministic output for novices preferred.

Dependency

Platform Format toolbar + Monaco #24 + parent platform ticket.

## Summary Provide **Python** code formatting once Monaco **Format document** piping exists for the playground — **browser-friendly** constraint (Pyodide) vs **server-backed** formatter. ## Options to evaluate — pick implementation time **A.** Run **Black** (or **`autopep8`**) inside **Pyodide** worker if WASM port available and deps acceptable. **B.** **Backend / code-execution microservice**: format user snippet with **`black`** (or Ruff `--format`), return text — aligns with graded runs already leaving the sandbox. **C.** Lighter PEP8-only heuristic (last resort — not parity with “Black”). ## Integration - Implement `provideDocumentFormattingEditProvider('python', …)` (or our Monaco language id). - **Latency UX**: spinner / cancel for slow WASM cold start. - **Teaching**: deterministic output for novices preferred. ## Dependency Platform Format toolbar + Monaco `#24` + parent platform ticket.
Author
Owner

Migrated to spikerj/spikersoft-angular#667 as part of the umbrella-tracker breakup.

Verified 2026-08-07 against spikersoft-angular@8e5a4048 and spikersoft-backend@98102023: no Python formatter provider in the Pyodide runner and no formatting endpoint on the backend; only JS/Prettier exists.

Status: not started — blocked on the shared Format toolbar (#35), which is also still open.

Closing here. Work now lives in the repo that holds the fix, so fixes #<N> in a PR will
auto-close it on merge. The umbrella tracker keeps cross-repo epics only.

— Opus 5 Agent

Migrated to **spikerj/spikersoft-angular#667** as part of the umbrella-tracker breakup. Verified 2026-08-07 against `spikersoft-angular@8e5a4048` and `spikersoft-backend@98102023`: no Python formatter provider in the Pyodide runner and no formatting endpoint on the backend; only JS/Prettier exists. Status: not started — blocked on the shared Format toolbar (#35), which is also still open. Closing here. Work now lives in the repo that holds the fix, so `fixes #<N>` in a PR will auto-close it on merge. The umbrella tracker keeps cross-repo epics only. — Opus 5 Agent
Sign in to join this conversation.