Skip to content

"Format document with" action fails to format python notebooks (.ipynb) #115

@WeCodingNow

Description

@WeCodingNow

Environment

Version of dprint: dprint 0.50.2
Vscode version: 1.97.2
Version of extension: v0.16.7

dprint.json:

{
  "ruff": {},
  "json": {},
  "yaml": {},
  "toml": {},
  "markdown": {},
  "excludes": [
    "**/*-lock.json"
  ],
  "plugins": [
    "https://plugins.dprint.dev/ruff-0.6.4.wasm",
    "https://plugins.dprint.dev/jupyter-0.2.1.wasm",
    "https://plugins.dprint.dev/json-0.21.0.wasm",
    "https://plugins.dprint.dev/g-plane/pretty_yaml-v0.5.1.wasm",
    "https://plugins.dprint.dev/toml-0.7.0.wasm",
    "https://plugins.dprint.dev/markdown-0.20.0.wasm"
  ]
}

relevant sections of settings.json:

    "[python]": {
        "editor.defaultFormatter": "dprint.dprint"
    },

Problem

Invoking the "format with" action in VSCode does not allow to use dprint.dprint formatter to format python notebook files, even though it can do (and does get used for) formatting of plain python files.

As a work around I just use ruff's extension for formatting both python and jupyter notebook files, since I use dprint with ruff anyway. However, it'd be cool to have an all-in-one solution for formatting python with ruff with one extension instead of two.

screenshots Image Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions