jupyterlab-code-formatter is a JupyterLab plugin that integrates popular code formatters (like Black, isort, Ruff, yapf, autopep8) directly into the JupyterLab IDE. It allows users to format their Python code within notebooks and script files via a context menu, menu bar, or keyboard shortcuts. The current version, 3.0.3, is designed for JupyterLab 3.x and 4.x, leveraging its modern extension system. It maintains an active development cycle with regular updates.
pip install jupyterlab_code_formatterNo compatibility data collected yet for this library.
Install the extension and your preferred code formatters (e.g., black, isort, ruff). After installation, restart your JupyterLab server. The formatting options will appear in the right-click context menu within a notebook cell or file editor, under the 'Format Code' menu, or via the 'Edit' menu. You can also configure keyboard shortcuts and default formatters in JupyterLab's Advanced Settings Editor.
Ensure your `jupyterlab-code-formatter` version matches your `jupyterlab` major version (e.g., `jupyterlab_code_formatter>=3` for `jupyterlab>=3`). Upgrade JupyterLab if necessary or downgrade the extension.
After installing `jupyterlab_code_formatter`, always run `pip install black isort ruff` (or your preferred formatters) to make them available to the extension.
If the extension doesn't appear after restarting JupyterLab, try running `jupyter lab build` in your terminal and then restart JupyterLab again. Clear browser cache if issues persist.
Open 'Settings' > 'Advanced Settings Editor' in JupyterLab, then select 'Code Formatter'. Ensure 'formatOnSave' or specific formatters are enabled and paths are correct if you've customized them. Save changes and restart JupyterLab if necessary.
Install the missing formatter: `pip install black` (or `isort`, `ruff`, etc.). Restart JupyterLab after installation.
Check for version compatibility (`jupyterlab-code-formatter` and `jupyterlab`). If versions match, try running `jupyter lab build` in your terminal, then clear your browser cache and restart JupyterLab. Ensure you've installed formatters.
You do not need to `import jupyterlab_code_formatter` in your Python code. Install it via `pip` and interact with its features directly through the JupyterLab UI (right-click menu, Edit menu, keyboard shortcuts).