Skip to content

Please use a formatter like Ruff or Pylint and post your config to GitLab #653

Open
@jtele2

Description

@jtele2

I'm having to reformat your python code on every pull. I'd highly recommend the ruff formatter, its fast and has a great vs code plugin. Just install it and set some settings (example below):

EXAMPLE RUFF CONFIG

# REFERENCE: https://docs.astral.sh/ruff/settings/#settings

# The native server supports Jupyter Notebooks out of the box. Unlike ruff-lsp, the 
# native server requires the user to explicitly include Jupyter Notebooks in the set of 
# files to lint and format. This can be done by updating the extend-include setting in 
# the Ruff configuration file.
extend-include = ["*.ipynb"]

[lint.isort]
force-single-line = true
lines-after-imports = 1

EXAMPLE VS CODE CONFIG

    // ########################NOTEBOOKS#########################
    "notebook.formatOnSave.enabled": true,
    "notebook.codeActionsOnSave": {
        "notebook.source.organizeImports": "explicit",
        "source.fixAll": "explicit"
    },
    //     "jupyter.stopOnFirstLineWhileDebugging": true, // Does not seem to work? 
    "jupyter.askForKernelRestart": false,
    "notebook.markup.fontSize": 14,
    "jupyter.notebookFileRoot": "${workspaceFolder}",
    // ##########################PYTHON##########################
    //     "python.analysis.autoImportCompletions": true,
    //     "python.analysis.autoFormatStrings": true,
    "[python]": {
        "editor.formatOnSave": true,
        "editor.defaultFormatter": "charliermarsh.ruff",
        "editor.codeActionsOnSave": {
            "source.organizeImports": "explicit",
            "source.fixAll": "explicit"
        },
    },
    // ##################### RUFF #####################
    "ruff.organizeImports": true,

Metadata

Metadata

Labels

improvementpythonPull requests that update Python code

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions