Skip to content

Run Black formatter and Isort in one command in a regular Python file. #295

@3h4

Description

@3h4

I'm trying to run Jupyterlab_code_formatter in a regular python file in Jupyter Lab. It is not formatted on save. I Can add a shortcut to manually run it:

  {
      "args": {},
      "command": "jupyterlab_code_formatter:black",
      "keys": [
          "Ctrl K",
          "Ctrl M"
      ],
      "selector": ".jp-CodeMirrorEditor"
  },

Can I add a shortcut to run both Isort and Black formatter? The following setting doesn't work:

{
  "shortcuts": [
    {
      "command": "apputils:run-all-enabled",
      "args": {
        "commands": ["jupyterlab_code_formatter:black", "jupyterlab_code_formatter:isort"],
      },
      "keys": [
        "Ctrl K",
        "Ctrl M"
      ],
      "selector": ".jp-CodeMirrorEditor"
    }
  ]
}

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