JupyterLab 3.0.14 How to disable code style highlights (pycodestyle)

6.5k views Asked by At

I just installed WPy64-3940 that comes with JupyterLab 3.0.14 .
To my surprise, now my code comes decorated with things called "pycodestyle".
As you can see below, the code is underlined in orange and a popup can appear.
I do not like that at all, it perturbs my reading.
Would you know where this comes from and how I can disable this?

Thanks
Michel

enter image description here

3

There are 3 answers

5
krassowski On

This is not a built-in feature of JupyterLab, but an extension called jupyterlab-lsp. As one of the authors I am surprised to see it included by default on the WPy64 distribution, and sorry you don't like it. Here are three potential solutions:

  1. Ignore this specific diagnostic message (recommended). Right click to bring up context menu and select "Show diagnostics panel"; hover mouse over the row with diagnostic message that you do not like, right click, select "Ignore diagnostics like this".

bring up context menu and select "Show diagnostics panel"

hover mouse over the row with diagnostic message that you do not like, right click, select "Ignore diagnostics like this"

  1. Disable pycodestyle diagnostic provider completely in setting of the language server. Click on "Settings" menu (top menu bar) → "Advanced Settings Editor" and choose "Language Servers" tab. Copy paste the following settings ("pyls" is the old server, "pylsp" is the new one - only one is needed but I do not know which one you are using); you can also disable other sources of diagnostics for this language server here:
{
  "language_servers": {
    "pyls": {
      "serverSettings": {
        "pyls": {
          "plugins": {
            "pydocstyle": {
              "enabled": false
            },
            "pyflakes": {
              "enabled": true
            },
            "flake8": {
              "enabled": false
            }
          }
        },
        "pylsp": {
          "plugins": {
            "pydocstyle": {
              "enabled": false
            },
            "pyflakes": {
              "enabled": true
            },
            "flake8": {
              "enabled": false
            }
          }
        }
      }
    }
  }
}
  1. Disable all diagnostics by going to "Diagnostics" tab and adding a catch-all regular-expression rule like this:
{
    "ignoreMessagesPatterns": [".*"]
}

enter image description here

  1. Disable the LSP extension altogether. It is probably best to consult whoever creates WPy64-3940 on how to do this.
0
MattC On

With JupyterLab in AWS SageMaker Studio, it is enabled by default. Which is annoying as it was not enabled with the previous Studio version, which they renamed Studio Classic. To get rid of the warning messages (some are really annoying and make no sense in a Notebook), I searched the settings. Here is where I was able to disable it:

Settings > Settings Editor > Language Servers

Click on 'pylsp' under 'AVAILABLE'

I then de-selected pylsp.plugins.pycodestyle

I disabled some other options as well, like pylsp.plugins.yapf, and pylsp.plugins.pylint

And I did not need to reload my workspace or anything, the error messages were just gone.

0
Stefan On

A. Disabling the complete code diagnostics worked to get rid of pycodestyle warnings:

enter image description here

B. There is a json editor shown on the top right of the settings editor that can be used to adapt the settings of the Languageserver.

enter image description here

C. Some aspects that might be confusing:

a) The settings depend on the installed version of jupyterlab-lsp. Update for example with

   pip install jupyterlab-lsp --upgrade
   pip install 'python-lsp-server[all]' --upgrade 

(Installation of a new version might delete your existing user preferences of the language server.)

Documentation of the current configuration style:

https://github.com/krassowski/jupyterlab-lsp#configuring-the-servers

b) When you copy the default settings to the right window, you cannot simply out comment the examples in the doc string to enable them. Instead, the code snippets need to be copied to the right location inside the main element "language_servers" and add some quotation marks around the keys.

c) In some versions, instead of the name "pycodestyle" a different term "pydocstyle" is used in the settings.

d) In some versions, the outdated term "pyls" has not been consistently replaced, yet.

D. Example settings to disable pycodestyle and pyflakes and enable pylint for jupyterlab-lsp version 4.2.0:

{
    // Language Server
    // @jupyter-lsp/jupyterlab-lsp:plugin
    // Language Server Protocol settings.
    // **********************************

    // Language Server
    // Language-server specific configuration, keyed by implementation, e.g: 
    // 
    // pyls: {
    //   serverSettings: {
    //     pyls: {
    //       plugins: {
    //         pydocstyle: {
    //           enabled: true
    //         },
    //         pyflakes: {
    //           enabled: false
    //         },
    //         flake8: {
    //           enabled: true
    //         }
    //       }
    //     }
    //   }
    // }
    // 
    // Alternatively, using dotted naming convention:
    // 
    // pyls: {
    //   serverSettings: {
    //     "pyls.plugins.pydocstyle.enabled": true,
    //     "pyls.plugins.pyflakes.enabled": false,
    //     "pyls.plugins.flake8.enabled": true
    //   }
    // }
    "language_servers": {
        "julia-language-server": {
            "serverSettings": {
                "julia.lint.run": true,
                "julia.lint.missingrefs": "none",
                "julia.lint.disabledDirs": [
                    "docs",
                    "test"
                ],
                "julia.lint.call": true,
                "julia.lint.iter": true,
                "julia.lint.nothingcomp": true,
                "julia.lint.constif": true,
                "julia.lint.lazy": true,
                "julia.lint.datadecl": true,
                "julia.lint.typeparam": true,
                "julia.lint.modname": true,
                "julia.lint.pirates": true,
                "julia.lint.useoffuncargs": true,
                "julia.completionmode": "qualify"
            }
        },
        "pylsp": {
            "serverSettings": {
                "pylsp.configurationSources": [
                    "pycodestyle"
                ],
                "pylsp.plugins.flake8.config": null,
                "pylsp.plugins.flake8.enabled": false,
                "pylsp.plugins.flake8.exclude": [],
                "pylsp.plugins.flake8.executable": "flake8",
                "pylsp.plugins.flake8.filename": null,
                "pylsp.plugins.flake8.hangClosing": null,
                "pylsp.plugins.flake8.ignore": [],
                "pylsp.plugins.flake8.maxLineLength": null,
                "pylsp.plugins.flake8.indentSize": null,
                "pylsp.plugins.flake8.perFileIgnores": [],
                "pylsp.plugins.flake8.select": null,
                "pylsp.plugins.jedi.extra_paths": [],
                "pylsp.plugins.jedi.env_vars": null,
                "pylsp.plugins.jedi.environment": null,
                "pylsp.plugins.jedi_completion.enabled": true,
                "pylsp.plugins.jedi_completion.include_params": true,
                "pylsp.plugins.jedi_completion.include_class_objects": true,
                "pylsp.plugins.jedi_completion.fuzzy": false,
                "pylsp.plugins.jedi_completion.eager": false,
                "pylsp.plugins.jedi_completion.resolve_at_most": 25,
                "pylsp.plugins.jedi_completion.cache_for": [
                    "pandas",
                    "numpy",
                    "tensorflow",
                    "matplotlib"
                ],
                "pylsp.plugins.jedi_definition.enabled": true,
                "pylsp.plugins.jedi_definition.follow_imports": true,
                "pylsp.plugins.jedi_definition.follow_builtin_imports": true,
                "pylsp.plugins.jedi_hover.enabled": true,
                "pylsp.plugins.jedi_references.enabled": true,
                "pylsp.plugins.jedi_signature_help.enabled": true,
                "pylsp.plugins.jedi_symbols.enabled": true,
                "pylsp.plugins.jedi_symbols.all_scopes": true,
                "pylsp.plugins.jedi_symbols.include_import_symbols": true,
                "pylsp.plugins.mccabe.enabled": true,
                "pylsp.plugins.mccabe.threshold": 15,
                "pylsp.plugins.preload.enabled": true,
                "pylsp.plugins.preload.modules": [],
                "pylsp.plugins.pycodestyle.enabled": false,
                "pylsp.plugins.pycodestyle.exclude": [],
                "pylsp.plugins.pycodestyle.filename": [],
                "pylsp.plugins.pycodestyle.select": [],
                "pylsp.plugins.pycodestyle.ignore": [],
                "pylsp.plugins.pycodestyle.hangClosing": null,
                "pylsp.plugins.pycodestyle.maxLineLength": null,
                "pylsp.plugins.pycodestyle.indentSize": null,
                "pylsp.plugins.pydocstyle.enabled": false,
                "pylsp.plugins.pydocstyle.convention": null,
                "pylsp.plugins.pydocstyle.addIgnore": [],
                "pylsp.plugins.pydocstyle.addSelect": [],
                "pylsp.plugins.pydocstyle.ignore": [],
                "pylsp.plugins.pydocstyle.select": [],
                "pylsp.plugins.pydocstyle.match": "(?!test_).*\\.py",
                "pylsp.plugins.pydocstyle.matchDir": "[^\\.].*",
                "pylsp.plugins.pyflakes.enabled": false,
                "pylsp.plugins.pylint.enabled": true,
                "pylsp.plugins.pylint.args": [],
                "pylsp.plugins.pylint.executable": null,
                "pylsp.plugins.rope_completion.enabled": false,
                "pylsp.plugins.rope_completion.eager": false,
                "pylsp.plugins.yapf.enabled": true,
                "pylsp.rope.extensionModules": null,
                "pylsp.rope.ropeFolder": null
            }
        },
        "r-languageserver": {
            "serverSettings": {
                "r.lsp.debug": true,
                "r.lsp.log_file": null,
                "r.lsp.diagnostics": true,
                "r.lsp.rich_documentation": true,
                "r.lsp.snippet_support": true,
                "r.lsp.max_completions": 200,
                "r.lsp.lint_cache": false,
                "r.lsp.link_file_size_limit": 16384
            }
        },
        "texlab": {
            "serverSettings": {
                "rootDirectory": null,
                "build.executable": "latexmk",
                "build.args": [
                    "-pdf",
                    "-interaction=nonstopmode",
                    "-synctex=1",
                    "%f"
                ],
                "build.onSave": false,
                "build.outputDirectory": ".",
                "build.forwardSearchAfter": false,
                "forwardSearch.executable": null,
                "forwardSearch.args": [],
                "chktex.onOpenAndSave": false,
                "chktex.onEdit": false,
                "diagnosticsDelay": 300,
                "formatterLineLength": 80,
                "latexFormatter": "latexindent",
                "latexindent.local": null,
                "latexindent.modifyLineBreaks": false
            }
        }
    },

    // Log all LSP communication with the LSP servers
    // Whether all messages sent to and received from LSP servers should be logged into the console. To see these messages, set loggingLevel to debug or log. Note: Only messages handled by the new API will be shown.
    "logAllCommunication": false,

    // Logging console type
    // The console to use for debugging problems with this extension. Allowed values are: browser, floating.
    "loggingConsole": "browser",

    // Logging console verbosity level
    // The verbosity of the console for debugging problems with this extension. Allowed values are: debug, log, warn, error.
    "loggingLevel": "warn",

    // Ask servers to send trace notifications
    // Whether to ask server to send logs with execution trace (for debugging). To see these messages, set loggingLevel to debug or log. Accepted values are: "off", "messages", "verbose". Servers are allowed to ignore this request.
    "setTrace": null
}

E: Configure pylint

You can specify the path to a pylint configuration file, for example

"pylsp.plugins.pylint.args": ["--rcfile ../../pyproject.toml"],