12/1/2021

Pylint

PyLint, a widely used tool that checks for errors in Python code and encourages good Python coding patterns, is integrated into Visual Studio for Python projects. Pylint is a Python static code analysis tool which looks for programming errors, helps enforcing a coding standard, sniffs for code smells and offers simple refactoring suggestions. It’s highly configurable, having special pragmas to control its errors and warnings from within your code, as well as from an extensive configuration file.

PyLint Integration

Pylint is a Python static code analysis tool which looks for programming errors, helps enforcing a coding standard, sniffs for code smells and offers simple refactoring suggestions. It’s highly configurable, having special pragmas to control its errors and warnings from within your code, as well as from an extensive configuration file. PyLint Configuration vs Severity Configuration in PyDev. In PyDev, you can specify the severity for each of the PyLint checkers in the preferences page, but PyLint will still make those analysis. If you want, you can disable the errors from being generated in PyLint itself. For instance, it's possible to pass:-disable=C -disable=R.


Wing Personal provides a simple integration with Pylint,which is a utility that runs coding style and error analyses on Python code. Thisintegration is omitted in Wing Pro, where the Code Warnings tool is used insteadto manage code warnings from a variety of sources, including Pylint.

To use the integration, you must install Pylint separately first and verify that it worksfrom the command line. Note that Pylint has certain dependencies that may be missing fromyour system. See the Pylint website for installation details.

Configuration

To configure Pylint in Wing, select the PyLint tool from the Tools menu, rightclick and choose Configure. This will open a configuration file in the editor,with the following options:

command is the command that invokes Pylint.

args specifies additional command line arguments to send to Pylint. Among otherthings, this can be used to disable some of Pylint's errors, warnings, and informationmessages. See the Pylint documentationfor details.

timeout is the maximum amount of time to wait for Pylint to complete before abortingthe process.

autosave controls if and how to auto-save editors before running Pylint. This canbe set to 0 to disable auto-saving, 1 to automatically save the file beinginspected, or 2 to auto-save all open files.

Pylint

Once you have edited the configuration file as desired, save and close it.

The configuration file may contain environment variable references in the form $(ENV)or ${ENV}, including references to regular environment variables defined in ProjectProperties or the special environment defined by Wing.

Per-project configuration is also possible. If a file .pylintrc exists in the samedirectory as a Wing project file, then this file name is passed to Pylint using the--rcfile argument. See the Pylint documentation for details on what this file can contain.

Pylint

Pylint Import Error

Running Pylint

To run Pylint on some code, bring up some Python source code in an editor in Wing, thenright-click on the PyLint tool, and select Update. The tool will indicate that itis in the process of updating. After some time, up to a minute for larger files, the tabswill be populated with errors, warnings, and informational messages returned from Pylint.Click on the items to display the referenced line of source code in the editor.

Processing Multiple Files

UpdateforPackage in the right-click context menu on the PyLint tool runs Pylinton all the files in the current package, when the current file is in a package (adirectory that contains a file __init__.py). In this case, the file name as well asthe line number is shown in the Line column of the output.

This option adds --output-format=parseable to the Pylint command line so that the filenames can be obtained. This may not work with all Pylint versions.

Pylint python

Pylintargs

Pylint

Using VirtualEnv on Windows

On Windows, Pylint installed into a virtualenv does not work because pylint.bat isinvoking just python and that may find the wrong Python installation. To fix this,edit pylint.bat and change python to the full path of the virtualenv's Python.

Credits

Thanks to Markus Meyer for providing the original implementation of this capability forWing. The source code for this integration is available as open source inscripts/pylintpanel.py within your Wing installation.

Pylint Install