Wing Tips: Python Code Warnings in Wing Pro

Oct 10, 2019

Wing Pro provides a code warnings system that flags likely errors as you work on Python code, using both Wing's built-in static analysis system and (optionally) external code checkers like Pylint, pep8, flake8, and mypy. Likely problems are indicated on the editor and listed in the Code Warnings tool:


Examples of warnings that Wing might flag include syntax errors, indentation problems, uses of an undefined variable, imports that cannot be resolved, or variables that are set but never used.

Code warnings save development time because they help to identify errors before code is even run. New code is checked as you work, although Wing will wait until you have finished typing so that it doesn't warn about code that is still being entered.

Navigating Warnings

Clicking on warnings in the Code Warnings tool or pressing the Enter key in the list navigates to that warning in the editor, highlighting it briefly with a callout, as configured from the Editor > Callouts preferences group.

The warning code warnings icon appears in the top right of any editor that has some code warnings. This can be clicked in order to jump to selected warnings in the file.

When code warnings are displayed on the editor, hovering the mouse cursor over the indicator will display details for that warning in a tooltip, as shown above.


The types of code warnings that Wing shows can be configured from the Configuration: Defaults page in the drop-down menu at the top of the Code Warnings tool. All the warnings Wing supports are documented in Warning Types. Some of these offer configuration options to control which variants of that type of warning will be shown:


Incorporating warnings found by external checkers like Pylint, pep8, flake8, and mypy is also done from this configuration page, as described previously in Using External Code Quality Checkers with Wing Pro 7

Disabling Warnings

Since all code checkers have only a limited understanding of what happens when code is actually run, they may show incorrect warnings. Wing allows you to disable warnings either for a single case, for an entire file, or for all files.

The quickest way to disable a warning is to press the red X icon that appears in the tooltips shown in the editor or in the currently selected item in the Code Warnings tool:


Wing disables most individual warnings only for the scope it appears in, so an identical problem in another scope will still be flagged. However, undefined attribute warnings are always disabled in all files where that attribute appears.

How it Works

When a warning is disabled, Wing adds a rule to the Configuration: Disabled Warnings page in the drop-down menu at the top of the Code Warnings tool:


Rules can be removed from here to reenable a warning, dragged between sections to control how widely the warning is being ignored, or edited by right-clicking in order to fine-tune the scope and nature of the rule.

For external checkers like Pylint, pep8, flake8, and mypy, warnings are disabled globally by the type of warning, making it relatively easy to develop a custom filter according to coding style and individual preference.

Resolving Imports

One thing to note here is that all the error checkers need some knowledge of your PYTHONPATH to trace down imports correctly. Often, no additional configuration is needed, but in cases where imports cannot be resolved you may need to add to the Python Path in Wing's Project Properties, from the Project menu.

Sharing Code Warnings Configurations

The current code warnings configuration, including all the warnings you have disabled, may be exported to the user settings area, or to a selected file from the Options menu in the Code Warnings tool. Projects may then share the configuration through the Use Configuration From item in the Code Warnings tool's Options menu:


The shared configuration file may be checked into revision control, so it can also be used by other developers working on your project.

That's it for now! We'll be back soon with more Wing Tips for Wing Python IDE.

Share this article: