<type>documentation</type>
<domain>edit</domain>
<id>pylint</id>
<title>PyLint Integration</title>
<date>$Date: 2007-09-25 14:02:53 -0400 (Tue, 25 Sep 2007) $</date>
<version>$Revision: 16486 $</version>
<product>per-only</product>

Wing Personal provides a simple integration with `Pylint <http://www.pylint.org/>`__,
which is a utility that runs coding style and error analyses on Python code.  This
integration is omitted in Wing Pro, where the Code Warnings tool is used instead
to manage code warnings from a variety of sources, including Pylint.

To use the integration, you must install Pylint separately first and verify that it works
from the command line. Note that Pylint has certain dependencies that may be missing from
your system. See the `Pylint <http://www.pylint.org/>`__ website for installation details.

**Configuration**

To configure Pylint in Wing, select the ``PyLint`` tool from the ``Tools`` menu, right
click 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 other
  things, this can be used to disable some of Pylint's errors, warnings, and information
  messages. See the `Pylint documentation <https://pylint.readthedocs.io/en/latest/>`__
  for details.
    
  **timeout** is the maximum amount of time to wait for Pylint to complete before aborting
  the process.
    
  **autosave** controls if and how to auto-save editors before running Pylint.  This can 
  be set to ``0`` to disable auto-saving, ``1`` to automatically save the file being
  inspected, or ``2`` to auto-save all open files.
  
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 `Project
Properties <ref:proj/project-properties>`__ or the `special environment
<ref:proj/variable-expansion>`__ defined by Wing.

Per-project configuration is also possible. If a file ``.pylintrc`` exists in the same
directory as a Wing project file, then this file name is passed to Pylint using the
``--rcfile`` argument. See the `Pylint documentation
<https://pylint.readthedocs.io/en/latest/>`__ for details on what this file can contain.

**Running Pylint**

To run Pylint on some code, bring up some Python source code in an editor in Wing, then
right-click on the ``PyLint`` tool, and select ``Update``. The tool will indicate that it
is in the process of updating. After some time, up to a minute for larger files, the tabs
will 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**

``Update for Package`` in the right-click context menu on the ``PyLint`` tool runs Pylint
on all the files in the current package, when the current file is in a package (a
directory that contains a file ``__init__.py``). In this case, the file name as well as
the 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 file
names can be obtained. This may not work with all Pylint versions.

**Using VirtualEnv on Windows**

On Windows, Pylint installed into a virtualenv does not work because ``pylint.bat`` is
invoking 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 for
Wing. The source code for this integration is available as open source in
``scripts/pylintpanel.py`` within your Wing installation.


