Using Mypy with SublimeText 3

In this article we’ll explore how to use mypy, a static-type checker for python, with the SublimeText 3 code editor(henceforth SBT3). We’ll need to install the mypy python package and a plugin for SBT3 called Anaconda. Anaconda adds various features to SBT3 like: code completion, linting, code analyzer, etc.

The end result will be type checks for our python code while we type or when saving/loading a file. Let’s get started.

1. Installing Mypy

Mypy can be easily installed with pip. We can use the pip module from our current python interpreter to ensure the package gets installed for our current python version, like so:

python3.6 -m pip install mypy

Note: If the installation fails because of missing dependencies, you may need to install python-dev for the python version in use and then retry the instalation:

sudo apt-get install python3.6-dev

Note: If installation is failing because of lack of permission, try to install mypy using the user’s home directory with the --user flag:

python3.6 -m pip install mypy --user

2. Installing Anaconda

The Anaconda plugin can be installed with the Package Control for SBT3 by simply searching for anaconda.

3. Configuring Anaconda

Next up, we need to configure anaconda. We’ll add the following configs into anaconda’s user settings(Preferences -> Package Settings -> Anaconda -> Settings-User):


    "python_interpreter": "python3.6",

    "anaconda_linting_behaviour": "load-save",

    "anaconda_linter_phantoms": true,

    "mypy": true,

Here we:

All options along with their explanations can be found in Anaconda -> Settings-Default.

4. Using it

With everything setup properly we should be getting the type checks from mypy alongside other lint checks.

mypy code checking example