Visual Studio Code Pylint



The Python Extension for Visual Studio Code is highly configurable. This page describes the key settings you can work with.

The Python Extension for Visual Studio Code is highly configurable. This page describes the key settings you can work with. For general information about working with settings in VS Code, refer to User and workspace settings, as well as the Variables reference for information about predefined variable support. Note: If you're looking to get started with Python in Visual Studio Code, refer to the tutorial Getting Started with Python in VS Code. Select and activate an environment. By default, the Python extension looks for and uses the first Python interpreter it finds in the system path.

For general information about working with settings in VS Code, refer to User and workspace settings, as well as the Variables reference for information about predefined variable support.

General settings

Setting
(python.)
DefaultDescription
condaPath'conda'Path to the conda executable.
pythonPath'python'Path to the Python interpreter, or the path to a folder containing the Python interpreter. Can use variables like ${workspaceFolder} and ${workspaceFolder}/.venv. Using a path to a folder allows anyone working with a project to create an environment in the .venv folder as appropriate to their operating system, rather than having to specify an exact platform-dependent path. The settings.json file can then be included in a source code repository.
pipenvPath'pipenv'Path to the pipenv executable to use for activation.
disableInstallationCheckfalseIf set to true, disables a warning from the extension if no Python interpreter is installed. On macOS, also disables a warning that appears if you're using the OS-installed Python interpreter. It's generally recommended to install a separate interpreter on macOS.
venvFolders[]Paths to folders where virtual environments are created. Depending on the virtualization tool used, it can be the project itself: ${workspaceFolder}, or separate folders for all virtual environments located side by side: .envs, ~/.virtualenvs, and so on.
envFile'${workspaceFolder}/
.env'
Absolute path to a file containing environment variable definitions. See Configuring Python environments - environment variable definitions file.
globalModuleInstallationfalseSpecifies whether to install packages for the current user only using the --user command-line argument (the default), or to install for all users in the global environment (when set to true). Ignored when using a virtual environment. For more information on the --userargument, see pip - User Installs.
poetryPath'poetry'Specifies the location of the Poetry dependency manager executable, if installed. The default value 'poetry' assumes the executable is in the current path. The Python extension uses this setting to install packages when Poetry is available and there's a poetry.lock file in the workspace folder.
terminal.launchArgs[]Launch arguments that are given to the Python interpreter when you run a file using commands such as Python: Run Python File in Terminal. In the launchArgs list, each item is a top-level command-line element that's separated by a space (quoted values that contain spaces are a single top-level element and are thus one item in the list). For example, for the arguments --a --b --c {'value1' : 1, 'value2' : 2}, the list items should be ['--a', '--b', '--c', '{'value1' : 1, 'value2' : 2}']. Note that Visual Studio code ignores this setting when debugging because it instead uses arguments from your selected debugging configuration in launch.json.
terminal.executeInFileDirfalseIndicates whether to run a file in the file's directory instead of the current folder.
terminal.activateEnvironmenttrueIndicates whether to automatically activate the environment you select using the Python: Select Interpreter command when a new terminal is created. For example, when this setting is true and you select a virtual environment, the extension automatically runs the environment's activate command when creating a new terminal (source env/bin/activate on macOS/Linux; envscriptsactivate on Windows).
terminal.activateEnvInCurrentTerminalfalseSpecifies whether to activate the currently open terminal when the Python extension is activated, using the virtual environment selected.
logging.levelerrorSpecifies the level of logging to be performed by the extension. The possible levels of logging, in increasing level of information provided, are off, error, warn, info, and debug. When set to off, which is not recommended, basic information will still be shown such as startup information and commands run by the Python extension. At the error level, basic information and errors will be shown. At the warn level, basic, error, and warning information will be shown. At the info level, basic, error, warning, and additional information like method execution times and return values will be shown. At this time, the debug level doesn't display additional information.
insidersChanneloffSpecifies whether to participate in the Insiders program and the channel to use. Set to weekly or daily to automatically download and install the latest Insiders builds of the Python extension, which include upcoming features and bug fixes.

Workspace symbol (tags) settings

Workspace symbols are symbols in C source code generated by the ctags tool (described on Wikipedia and on ctags.sourceforge.net). To quote Wikipedia, ctags 'generates an index (or tag) file of names found in source and header files of various programming languages.' Where Python is concerned, ctags makes it easier to jump to defined functions and other symbols in C/C++ extension modules.

Setting
(python.workspaceSymbols.)
DefaultDescription
tagFilePath'${workspaceFolder}/
.vscode/tags'
Fully qualified path to tag file (an exuberant ctag file), used to provide workspace symbols.
enabledtrueSpecifies whether to enable the Workspace Symbol provider.
rebuildOnStarttrueSpecifies whether to rebuild the tags file on start.
rebuildOnFileSavetrueSpecifies whether to rebuild the tags file on when saving a Python file.
ctagsPath'ctags'Fully qualified path to the ctags executable; default value assumes it's in the current environment.
exclusionPatterns['**/site-packages/**']Pattern used to exclude files and folders from ctags.

Code analysis settings

IntelliSense engine settings

Setting
(python.)
DefaultDescription
jediPath'Path to folder containing the Jedi library (folder should contain a jedi subfolder).
jediMemoryLimit0Memory limit for the Jedi completion engine in megabytes. Zero (the default) means 1024 MB. -1 disables the memory limit check.
languageServerJediDefines type of the language server (Microsoft, Jedi, None). Note that the language server requires a platform that supports .NET Core 2.1 or newer.

Python Language Server settings

The language server settings apply when python.jediEnabled is false. If you have any difficulties with the language server, see Troubleshooting in the language server repository.

Visual Studio Code Pylint Unable To Import

Setting
(python.analysis.)
DefaultDescription
diagnosticPublishDelay1000The number of milliseconds to wait before transferring diagnostic messages to the problems list.
disabled
errors
warnings
information
[]List of diagnostics messages to suppress or show as errors, warnings, or information. See below for applicable values. The classification of messages affects both what's shown in the Problems window and in the editor (such as the color of the underlining).
logLevel'Error'Defines the types of log messages that language server writes into the Problems window, one of 'Error', 'Warning', 'Information', and 'Trace'. The 'Warning' level implicitly includes 'Error'; 'Information' implicitly includes 'Warning' and 'Error'; 'Trace' includes all messages.
openFilesOnlytrueWhen true, shows only errors and warnings for open files rather than for the entire workspace.
symbolsHierarchyDepthLimit10Limits the depth of the symbol tree in the document outline.
typeshedPaths[]Paths to look for typeshed modules on GitHub.

The disabled, errors, warnings, and information settings can contain the following values:

ValueDefault typeDescription or message text
inherit-non-classWarningAttempted to inherit something that is not a class.
too-many-function-argumentsWarningToo many arguments have been provided to a function call.
too-many-positional-arguments-before-starWarningToo many arguments have been provided before a starred argument.
no-cls-argumentWarningFirst parameter in a class method must be cls.
no-method-argumentWarningMethod has no arguments.
no-self-argumentWarningFirst parameter in a method must be self.
parameter-already-specifiedWarningA argument with this name has already been specified.
parameter-missingWarningA required positional argument is missing.
positional-argument-after-keywordWarningA positional argument has been provided after a keyword argument.
positional-only-namedWarningA positional-only argument (3.8+) has been named in a function call.
return-in-initWarningEncountered an explicit return in __init__ function.
typing-generic-argumentsWarningAn error occurred while constructing Generic.
typing-typevar-argumentsWarningAn error occurred while constructing TypeVar.
typing-newtype-argumentsWarningAn error occurred while constructing NewType.
unknown-parameter-nameWarningThe keyword argument name provided is unknown.
unresolved-importWarningAn import cannot be resolved, and may be missing.
undefined-variableWarningA variable has been used that has not yet been defined.
variable-not-defined-globallyWarningA variable is not defined in the global scope.
variable-not-defined-nonlocalWarningA variable is not defined in non-local scopes.

To suppress the 'undefined-variable' messages, for example, use the setting 'python.analysis.disabled': ['undefined-variable']. To suppress those messages and 'too-many-function-arguments' messages as well, use the setting 'python.analysis.disabled': ['undefined-variable', 'too-many-function-arguments']. You can similarly set 'python.analysis.errors', 'python.analysis.warnings', and 'python.analysis.information' to control the visibility and severity of the diagnostics.

AutoComplete settings

Setting
(python.autoComplete.)
DefaultDescriptionSee also
addBracketsfalseSpecifies whether VS Code automatically adds parentheses (()) when autocompleting a function name.Editing
extraPaths[]Specifies locations of additional packages for which to load autocomplete data.Editing

Formatting settings

Setting
(python.formatting.)
DefaultDescriptionSee also
provider'autopep8'Specifies the formatter to use, either 'autopep8', 'black', or 'yapf'.Editing - Formatting
autopep8Path'autopep8'Path to autopep8Editing - Formatting
autopep8Args[]Arguments for autopep8, where each top-level element that's separated by a space is a separate item in the list.Editing - Formatting
blackPath'black'Path to blackEditing - Formatting
blackArgs[]Arguments for black, where each top-level element that's separated by a space is a separate item in the list.Editing - Formatting
yapfPath'yapf'Path to yapfEditing - Formatting
yapfArgs[]Arguments for yapf, where each top-level element that's separated by a space is a separate item in the list.Editing - Formatting

Refactoring - Sort Imports settings

Setting
(python.sortImports.)
DefaultDescriptionSee also
path'Path to isort scriptEditing - Refactoring - Sort Imports
args[]Arguments for isort, each argument as a separate item in the array.Editing - Refactoring - Sort Imports

Linting settings

General

PylintPylintrc
Setting
(python.linting.)
DefaultDescriptionSee also
enabledtrueSpecifies whether to enable linting in general.Linting
lintOnSavetrueSpecifies whether to line when saving a file.Linting
maxNumberOfProblems100Limits the number of linting messages shown.Linting
ignorePatterns['.vscode/*.py', '**/site-packages/**/*.py']Exclude file and folder patterns.Linting

Pylint

Setting
(python.linting.)
DefaultDescriptionSee also
pylintEnabledtrueSpecifies whether to enable Pylint.Linting
pylintArgs[]Additional arguments for Pylint, where each top-level element that's separated by a space is a separate item in the list.Linting
pylintUseMinimalCheckerstrueSpecifies whether to use the default value for pylintArgs.Linting
pylintPath'pylint'The path to Pylint.Linting
pylintCategorySeverity.convention'Information'Mapping for Pylint convention message to VS Code type.Linting
pylintCategorySeverity.refactor'Hint'Mapping for Pylint refactor message to VS Code type.Linting
pylintCategorySeverity.warning'Warning'Mapping for Pylint warning message to VS Code type.Linting
pylintCategorySeverity.error'Error'Mapping for Pylint error message to VS Code type.Linting
pylintCategorySeverity.fatal'Error'Mapping for Pylint fatal message to VS Code type.Linting

pycodestyle (pep8)

Setting
(python.linting.)
DefaultDescriptionSee also
pycodestyleEnabledfalseSpecifies whether to enable pycodestyle.Linting
pycodestyleArgs[]Additional arguments for pycodestyle, where each top-level element that's separated by a space is a separate item in the list.Linting
pycodestylePath'pycodestyle'The path to pycodestyle.Linting
pycodestyleCategorySeverity.W'Warning'Mapping for pycodestyle W message to VS Code type.Linting
pycodestyleCategorySeverity.E'Error'Mapping for pycodestyle E message to VS Code type.Linting
Visual Studio Code Pylint

Flake8

Setting
(python.linting.)
DefaultDescriptionSee also
flake8EnabledfalseSpecifies whether to enable flake8.Linting
flake8Args[]Additional arguments for flake8, where each top-level element that's separated by a space is a separate item in the list.Linting
flake8Path'flake8'The path to flake8.Linting
flake8CategorySeverity.F'Error'Mapping for flake8 F message to VS Code type.Linting
flake8CategorySeverity.E'Error'Mapping for flake8 E message to VS Code type.Linting
flake8CategorySeverity.W'Warning'Mapping for flake8 W message to VS Code type.Linting

mypy

Setting
(python.linting.)
DefaultDescriptionSee also
mypyEnabledfalseSpecifies whether to enable mypy.Linting
mypyArgs['--ignore-missing-imports', '--follow-imports=silent']Additional arguments for mypy, where each top-level element that's separated by a space is a separate item in the list.Linting
mypyPath'mypy'The path to mypy.Linting
mypyCategorySeverity.error'Error'Mapping for mypy error message to VS Code type.Linting
mypyCategorySeverity.note'Information'Mapping for mypy note message to VS Code type.Linting

pydocstyle

Setting
(python.linting.)
DefaultDescriptionSee also
pydocstyleEnabledfalseSpecifies whether to enable pydocstyle.Linting
pydocstyleArgs[]Additional arguments for pydocstyle, where each top-level element that's separated by a space is a separate item in the list.Linting
pydocstylePath'pydocstyle'The path to pydocstyle.Linting

prospector

Setting
(python.linting.)
DefaultDescriptionSee also
prospectorEnabledfalseSpecifies whether to enable prospector.Linting
prospectorArgs[]Additional arguments for prospector, where each top-level element that's separated by a space is a separate item in the list.Linting
prospectorPath'prospector'The path to prospector.Linting

pylama

Setting
(python.linting.)
DefaultDescriptionSee also
pylamaEnabledfalseSpecifies whether to enable pylama.Linting
pylamaArgs[]Additional arguments for pylama, where each top-level element that's separated by a space is a separate item in the list.Linting
pylamaPath'pylama'The path to pylama.Linting

Testing settings

General settings

Code
Setting
(python.testing.)
DefaultDescriptionSee also
cwdnullSpecifies an optional working directory for tests.Testing
promptToConfiguretrueSpecifies whether VS Code prompts to configure a test framework if potential tests are discovered.Testing
debugPort3000Port number used for debugging of unittest tests.Testing
autoTestDiscoverOnSaveEnabledtrueSpecifies whether to enable or disable auto run test discovery when saving a test file.Testing

unittest framework

Setting
(python.testing.)
DefaultDescriptionSee also
unittestEnabledfalseSpecifies whether unittest is enabled for testing.Testing
unittestArgs['-v', '-s', '.', '-p', '*test*.py']Arguments to pass to unittest, where each top-level element that's separated by a space is a separate item in the list.Testing

pytest framework

Setting
(python.testing.)
DefaultDescriptionSee also
pytestEnabledfalseSpecifies whether pytest is enabled for testing.Testing
pytestPath'py.test'Path to pytest. Use a full path if pytest is located outside the current environment.Testing
pytestArgs[]Arguments to pass to pytest, where each top-level element that's separated by a space is a separate item in the list. When debugging tests with pytest-cov installed, include --no-cov in these arguments.Testing

Nose framework

Setting
(python.testing.)
DefaultDescriptionSee also
nosetestsEnabledfalseSpecifies whether Nose is enabled for testing.Testing
nosetestPath'nosetests'Path to Nose. Use a full path if pytest is located outside the current environment.Testing
nosetestArgs[]Arguments to pass to Nose, where each top-level element that's separated by a space is a separate item in the list.Testing

Predefined variables

The Python extension settings support predefined variables. Similar to the general VS Code settings, variables use the ${variableName} syntax. Specifically, the extension supports the following variables:

  • ${cwd} - the task runner's current working directory on startup

  • ${workspaceFolder} - the path of the folder opened in VS Code

  • ${workspaceRootFolderName} - the name of the folder opened in VS Code without any slashes (/)

  • ${workspaceFolderBasename} - the name of the folder opened in VS Code without any slashes (/)

  • ${file} - the current opened file

  • ${relativeFile} - the current opened file relative to workspaceFolder

  • ${relativeFileDirname} - the current opened file's dirname relative to workspaceFolder

  • ${fileBasename} - the current opened file's basename

  • ${fileBasenameNoExtension} - the current opened file's basename with no file extension

  • ${fileDirname} - the current opened file's dirname

  • ${fileExtname} - the current opened file's extension

  • ${lineNumber} - the current selected line number in the active file

  • ${selectedText} - the current selected text in the active file

  • ${execPath} - the path to the running VS Code executable

For additional information about predefined variables and example usages, see the Variables reference in the general VS Code docs.

Next steps

  • Python environments - Control which Python interpreter is used for editing and debugging.
  • Editing code - Learn about autocomplete, IntelliSense, formatting, and refactoring for Python.
  • Linting - Enable, configure, and apply a variety of Python linters.
  • Debugging - Learn to debug Python both locally and remotely.
  • Testing - Configure test environments and discover, run, and debug tests.

Linting within the extension is supported on the following:

  • Pylint (this is the default linter used)

Paths

All samples provided here are for windows.
However Mac/Linux paths are also supported.

Note: You could enable all of the above linters if necessary. Or just one or two of them.
This can be achieved by enabling/disabling individual linters.

Lint as you type

Linting as you type can be enabled by turning on the ‘auto save’ feature in Visual Studio Code…
Follow the instructions here to turn on auto save.

Enable/Disable Linting

By default linting is enabled and uses pylint.
If you wish to turn this off, you could do so either in the User Settings or the Workspace Settings file.
Enabling/disabling could be done by configuring the following property in either one of (User or Workspace settings file) as follows:

The extension will run the linter when ever a file is saved.
This can easily be turned off, once again either within the User or Workspace Settings files with the following configuration change:

Maximum number of messages

The default maximum number of messages displayed in Visual Studio Code is limited to 100.
If this is to be altered, then change the following configuration settings either in the User or Workspace settings file:

Pylint

As mentioned previously, this is the default linter used by the extension.

Installing PylintFor this to work properly ensure pylint is installed locally.
You can easily install pylint as follows:
pip install pylint

Enabling/Disabling pylintIf the pylint linter is not to be used by the extension, then disable it as follows either in the User or Workspace settings file:

Custom PathThis is generally unnecessary. As the Extension will resolve the path to the formatter based on Python executable being used or configured in python.pythonPath of settings.json. If this cannot be found, then the formatter will be resolved based on the current environment Path settings.

If this is not the case or you wish to use another version of pylint, all you need to do is configure the path as follows either in the User or Workspace settings file:

Pylint Category MappingMessages generated by pylint fall into the following categories:

  • convention, refactor, warning, error, fatal
    Visual Studio Code supports the following categories in linting:
  • Hint, Error, Information, WarningBy default the extension maps pylint “convention” to “Hint”, and so on.
    These mappings can be altered either in the User or Workspace settings files as follows:

Custom ConfigurationYou can customize the linter by providing a configuration file for pylint and placing it in the necessary location.
For instance you could place a pylintrc or .pylintrc file in the workspace folder.For further details please refer Pylint Command Line Options

Pylint Plugins or custom arguments to PyLintCustom plugins such as pylint plugin for Django can be easily used by modifying the User or Workspace settings as follows:

Pep8

As mentioned previously, usage of this linter is turned off by the extension.

Linter pylint visual studio code

Installing Pep8For this to work properly ensure Pep8 is installed locally.
You can easily install pep8 as follows:
pip install pep8

Enabling/Disabling pep8If the pep8 linter is to be used by the extension, then enable it as follows either in the User or Workspace settings file:

Efilm for mac os. Custom PathThis is generally unnecessary. As the Extension will resolve the path to the formatter based on Python executable being used or configured in python.pythonPath of settings.json. If this cannot be found, then the formatter will be resolved based on the current environment Path settings.

If this is not the case or you wish to use another version of pep8, all you need to do is configure the path as follows either in the User or Workspace settings file:

Custom ConfigurationThe options are read from the [pep8] section of the tox.ini file or the setup.cfg file located in any parent folder of the path(s) being processed.
For further details refer the following Options.

Flake8

As mentioned previously, usage of this linter is turned off by the extension.

Installing Flake8For this to work properly ensure Flake8 is installed locally.
You can easily install flake8 as follows:
pip install flake8

Enabling/Disabling flake8If the flake8 linter is to be used by the extension, then enable it as follows either in the User or Workspace settings file:

Custom PathThis is generally unnecessary. As the Extension will resolve the path to the formatter based on Python executable being used or configured in python.pythonPath of settings.json. If this cannot be found, then the formatter will be resolved based on the current environment Path settings.

If this is not the case or you wish to use another version of pep8, all you need to do is configure the path as follows either in the User or Workspace settings file:

Custom ConfigurationThe user settings are read from the ~/.config/flake8 file (or the ~/.flake8 file on Windows).
At the project level, a tox.ini file or a setup.cfg file is read if present. Only the first file is considered. If this file does not have a [flake8] section, no project specific configuration is loaded.
For further details refer Configuration.

mypy

As mentioned previously, usage of this linter is turned off by the extension.

Installing mypyFor this to work properly ensure mypy is installed locally.
You can easily install mypy as follows:
pip3 install mypy-lang

Install Pylint Visual Studio Code

Enabling/Disabling mypyIf the mypy linter is to be used by the extension, then enable it as follows either in the User or Workspace settings file:

Custom PathThis is generally unnecessary. As the Extension will resolve the path to the formatter based on Python executable being used or configured in python.pythonPath of settings.json. If this cannot be found, then the formatter will be resolved based on the current environment Path settings.

Node Js Downloads

If this is not the case or you wish to use another version of mypy, all you need to do is configure the path as follows either in the User or Workspace settings file:

Visual Studio

Custom ConfigurationCustom command line arguments can be passed into mypy just as with the other linters using the setting: Open doc for mac.

pylama

As mentioned previously, usage of this linter is turned off by the extension.

Installing mypyFor this to work properly ensure mypy is installed locally.
You can easily install pylama as follows:
pip install pylama

Enabling/Disabling pylamaIf the pylama linter is to be used by the extension, then enable it as follows either in the User or Workspace settings file:

Custom PathThis is generally unnecessary. As the Extension will resolve the path to the formatter based on Python executable being used or configured in python.pythonPath of settings.json. If this cannot be found, then the formatter will be resolved based on the current environment Path settings.

If this is not the case or you wish to use another version of mypy, all you need to do is configure the path as follows either in the User or Workspace settings file:

Visual Studio Code Pylint 2020

Custom ConfigurationCustom command line arguments can be passed into pylama just as with the other linters using the setting: