Search code examples
pythonvisual-studio-codepylint

Pylint in VSCode is not reading the configuration in settings.json


I installed Pylint v2023.11.13481007 (pre-release) in VSCode 1.86.1 and it works in vanilla install, i.e., no config settings. I run VSCode on a Windows machine with a remote SSH connection to a Mac laptop, so the Pylint extension is enabled on the remote SSH host. The remote host is running Python 3.10.9 and Pylint Python 2.16.2.

The trouble is that I cannot get Pylint to read a custom config settings file. Here's what I have tried:

  • I set two Pylint config variables in File > Preferences > Settings. Then I saw that vscode created a file on the remote mac laptop, ~/.vscode-server/data/Machine/settings.json, with the lines below. But Pylint did not use these settings.

      {
          "pylint.args": [
              "--max-line-length=99"
          ],
          "pylint.lintOnChange": true
      }
    
  • I restarted Pylint. I restarted VSCode. The settings are still not used.

  • I copied the settings.json file to $PROJECT/.vscode/settings.json and restarted. No change in behavior.

  • I reverted Pylint to the v2023.10.1 (release) version. Still no settings change. No change in behavior.

Pylint is reporting lots of errors. Most of them are "line too long", because it is not using the custom setting. But it also only lints when I save a file. So both settings are ignored.

How do I get Pylint to use custom configuration setting in this environment?


Solution

  • Try adding a .pylintrc configuration file at the same level as the .vscode folder. In this file, add the codes for the lint messages you want to ignore. In the example below we ignore long-lines, too-many-attributes, and too-many-arguments. You can look up code information here.

    [MESSAGES CONTROL]
    disable=C0103,R0902,R0913
    

    For pylintrc, you may not have to restart VS Code, just re-open the code file.