Mastodon

Roll Your Own Python IDE, Part Deux

It’s been one year since I attempted to cobble together a Python IDE with Atom, and surprise! It’s still here. A lot has changed though, to say the least, so I thought I’d take a moment to share my current setup.

Atom IDE

Atom IDE

Some higher-ups at Facebook must have read my first post because a few months after GitHub announced Atom-IDE, a set of extensible packages designed to bring IDE-like functionality to Atom (alas, Python was not on the list of initially-supported languages, but was mentioned as hopefully coming soon). It initially boasted features such as autocomplete, diagnostics, find all references, go to definition, hover, and an outline view. That last feature was very much welcomed after being spoiled by Xcode.

Sure enough, less than two weeks later, ide-python appeared, providing Python support with atom-ide-ui and the Python language server. There are a variety of providers supplied by the Python language server, and it’s worth giving each a quick mention.

Jedi

No, not the Force-weilding guardians of peace, Jedi is a static analysis library that provides autocompletion suggestions (And hopefully linting and refactoring in the future).

Rope

I’m not going to rope you into suffering a horrible pun for every one of these. Rope provides refactoring, and can be configured on a per-project basis, with settings living in the .ropeproject folder at the root of your project.

Pyflakes

Pyflakes helps ensure your code doesn’t flake on execution (I’m so sorry) by parsing source files for errors.

McCabe

McCabe measures the cyclomatic complexity of source code. You hopefully shouldn’t be seeing too many warnings from this, but it’s nice to know it’s there.

pycodestyle

Formerly known as pep8, pycodestyle checks your code against the one true style convention, PEP 8

The quickest way to get up and running with ide-python is to install the atom package and its dependencies with:

pydocstyle

Pydocstyle is pycodestyle for documentation (Which I know you’re all including). I recommend adding “D100” to the list of warnings to ignore, thanks to numpy.

YAPF

YAPF (Yet Another Python Formatter), is yet another python formatter from Google. It’s based on clang-format, and is highly configurable. It fixes the problem of autopep8 and other formatters that only reformat code to make it PEP 8 compliant, and won’t touch compliant code, no matter how atrocious. To enable this glorious tool, you have to disable autopep8, as ide-python will prefer it over YAPF.

Installing up ide-python and its dependencies is pretty simple:

$
apm install ide-python atom-ide-ui

And then install the python language server with all supported features:

$
pip install 'python-language-server[all]'

Of course if you don’t want all of the features *cough* autopep8 *cough*, you can simply disable them in ide-python’s settings, or follow the official installation instructions to skip the unwanted providers.

Debugging

While the original DIY Python IDE did feature a debugger, it left much to be desired. Atom IDE has an excellent debugger module with Python support that integrates beautifully. Breakpoints can be set in the gutter, and controls are to the right of the editing area. Underneath is the console tab which supports REPL.

Atom IDE Debugger

As you may have guessed, installation is a breeze:

$
apm install atom-ide-debugger-python

Atom’s customizability and extensibility gives it incredible potential, and IDE features are a tremendous example of the power of the platform. I’m excited to see where it will go in the future.