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

Open
opened 2026-04-28 23:48:47 +00:00 by spikerj · 0 comments
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.
Sign in to join this conversation.