Last Site Update: July 23rd, 2021 | Latest Version: 8.3.0


Main

Download

Screenshots

Manual

Developers

About/Contact


PyDev LiClipse




Previous (PyLint) Root Next (Quick Outline)


MyPy can be used with PyDev

Note that type checking with MyPy is disabled by default.

To activate it, go to the MyPy preferences page, and then check Use MyPy.

images/mypy/mypy_prefs.png

The integration is done so that when the PyDev code analysis is passed on a saved file, MyPy will also be run on that file (so, the PyDev code analysis must also be turned on for the MyPy analysis to be done).

What's the differences from the PyDev code analysis to MyPy?

The main difference is that PyDev doesn't really do type checking while MyPy does.

In practice, this means that MyPy catches a whole range of errors that PyDev doesn't (but it's also considerably slower to run).

Also, MyPy will only run in files that are saved in the disk (so, the PyDev code analysis can work on the editor contents while MyPy can't).

Files analyzed

Note that the MyPy code analysis will only be run in the currently opened editor (right after opening it or when the file is saved) and only if the file is actually in the PYTHONPATH (i.e.: it needs to be under a source folder, have a valid Python name and have __init__.py files in each package to access it).

Forcing analysis without open editor

It's possible to force running code analysis on files which are not opened in an editor by right-clicking a folder and choosing the menu PyDev > Code Analysis.

images/pylint/ask_code_analysis.png

The problems flagged by MyPy can then be seen at the Problems view (it can be accessed by using Ctrl+3 and then typing Problems).

Forcing file to be reanalyzed in open editor

Usually, when the editor is opened, the analysis will run automatically, and whenever the file is saved, it'll be rerun, but it's also possible to force running the analysis by using:

Ctrl+2, C

That'll force the code to be re-analyzed (which may be useful if you're tweaking your settings on MyPy). Note that MyPy will always work on the file on the disk (so, if your file is changed in the editor, the results from MyPy may not match what you're seeing in the editor).

Ignoring a MyPy message

PyDev allows users to ignore a given MyPy message in a given line by adding a #noqa comment.

Troubleshooting

If the option to run MyPy is enabled and results are not being shown, the first step is taking a look into the Error Log (it can be accessed by using Ctrl+3 and then typing Error Log).

If the error log shows an entry such as Unable to find mypy, it means that MyPy is not being found in the related Python interpreter. To fix this issue either install MyPy in the related interpreter or specify the MyPy executable to be used.

If there is no error in the Error Log, please check the option Redirect MyPy output to console? in the MyPy preferences. This should create a new console view which will be shown when MyPy making its output visible to be able to diagnose what may be happening.

If you still can't get it to work, please ask on StackOverflow (with a PyDev tag).





Previous (PyLint) Root Next (Quick Outline)

PyDev development

PyDev is open source and depends on your contributions! This may be in the form of bug fixes, answers on stackoverflow, new features...

Another option is financially supporting it at: Patreon (which provides a way to support it monthly and get rewards starting with $1).



Or through 1-time contributions at:

  Paypal




Search PyDev-related content







Copyright: Brainwy Software Ltda, 2014-2021