20 ATOM Plug-ins For Python Development

October 9, 2018

1. IDE-python package

Feature Providers

  • Jedi for Completions, Definitions, Hover, References, Signature Help, and Symbols
  • Rope for Completions and renaming
  • Pyflakes linter to detect various errors
  • McCabe linter for complexity checking
  • pycodestyle linter for style checking
  • pydocstyle linter for docstring style checking
  • autopep8 for code formatting (preferred over YAPF)
  • YAPF for code formatting

Installation Language Server Install the language server (0.19.0 or newer) with.

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

This command will install the language server and all supported feature providers, which can be enabled or disabled in the settings.

You can verify that everything is correctly installed by running python -m pyls --help from the command line. It should return

usage: pyls [-h] [--tcp] [--host HOST] [--port PORT]
            [--log-config LOG_CONFIG | --log-file LOG_FILE] [-v]

Python Language Server
...

If you have installed pyls using a non default installation of Python, you can add modify the Python Executableconfig in the ide-python settings.

Atom Package Install ide-python and atom-ide-ui from Install in Atom's settings or run.

apm install atom-ide-ui
apm install ide-python

Configuration

  • pycodestyle: discovered in ~/.config/pycodestyle, setup.cfg, tox.ini and pycodestyle.cfg
  • flake8: discovered in ~/.config/flake8, setup.cfg, tox.ini and flake8.cfg

The configuration is computed first from user configuration (in home directory), overridden by configuration in the ide-python settings, and then overridden by configuration discovered in the current project.

2. atom-python-run package

Run your python (.py) source file using F5 or F6!

Prerequisite

  • Atom Text Editor (nightly or latest stable release)
  • Python 2 and/or 3
  • Add Python (and any other interpreters) to the PATH environment variable.
  • Features*
  • Using python
  • Almost the same console with python IDLE, which provides syntax error and runtime error messages.
  • It is a rough time based on real time rather than CPU kernel / user time

Compatibility

  • Cross Platform Compatible
  • Runs on Windows, Mac OS X, and Linux
  • True Arbitrary Execution
  • Global python is the default interpreter
  • Execute using any interpreter
  • Pass options to the given interpreter
  • Pass arguments to the program to be executed
  • Python 2 and 3

Note: If you have problems executing, you can install a global version of latest python2.7.x (even if you have python3.x.x installed). Please report any python3 issues if you want to avoid installing a global python2 version.

3. Python Black for Atom editor

Uses Black for formatting Python code.

Requirements Make sure you have black installed and the correct path to binary was set in the package config.

pip install black

Keymap "ctrl-alt-c": "python-black:format" Configuration

python-black:
  binPath: "black"
  fmtOnSave: true
  lineLength: 88
  skipStringNormalization: false

4. Python Tools

Details This package uses Jedi in addition to other custom code to provide numerous pieces of functionality to make you more productive: Show Usages Default shortcut: ctrl+alt+u 9aeef9137362fe1d6147164597ff91bd.gif Select the usages of a specific symbol in your file. This is for handy for quickly refactoring/renaming variables and other symbols within your code. Currently only supports detection of symbols within the same file. This will be extended to support usages outside the current file in the future. Goto Definition Default shortcut: ctrl+alt+g fb8d677fc8a13a95e99edab1b86aed9d.gif Go to to the original definition of the symbol under the cursor. This will open the corresponding file if it is not already open. Files which form part of the standard library / are installed as third party modules are still opened, which is a really nice way of analysing and understanding behavior of code. Select String Contents Default shortcut: ctrl+alt+e be4f4211ddea07eab88f82c9bca2ce83.gif

Select the entire contents of the string currently being selected. Works with single line as well as block strings.

5. atom-python-yapf

Atom.io plugin to format Python files using Google's YAPF

Install apm install python-yapf Or Settings/Preferences ➔ Packages ➔ Search for python-yapf Make sure you have YAPF installed and the correct path to binary was set in the package config. Settings 354baf72b34561f09cc25489599a5106.png

Keymap Currently, there are two commands: python-yapf:formatCode - for formatting python code python-yapf:checkCode - for checking format of python code

6. build-python

Installation apm Install build-python from Atom's Package Manager or the command-line equivalent:

$ apm install build-python

Using Git Change to your Atom packages directory:

# Windows 
$ cd %USERPROFILE%\.atom\packages

# Linux & macOS 
$ cd ~/.atom/packages/

Clone repository as build-python:

$ git clone https://github.com/idleberg/atom-build-python build-python

Inside the cloned directory, install Node dependencies:

$ yarn || npm install

Build Before you can build, select an active target with your preferred build option. Available targets:

  • Python — compile script
  • Python (compileall) — compile script with -m compileall
  • Python (compileall, optimized) — compile script with -O -m compileall
  • Python (user) — compile script with custom settings (interpreter and/or arguments)
  • Shortcuts* Here's a reminder of the default shortcuts you can use with this package:
  • Select active target Cmd+Alt+T or F7
  • Build script Cmd+Alt+B or F9
  • Jump to error Cmd+Alt+G or F4
  • Toggle build panel Cmd+Alt+V or F8

7. Atom-Python-test

Requirements

  • You need py.test installed to use this package:
    pip install pytest
    When using virtualenv, the recommended workflow is:
  • Activate your virtualenv on terminal.
  • Run atom editor, so this plug-in will get py.test from virtualenv (or use atom-python-virtualenv plug-in).
  • Usage* 1) Running all tests (Ctrl + Alt + T) 2) Run test under cursor (Ctrl + Alt + C) 3) Hide the execution panel (Ctrl + Alt + H)

The plug-in supports to color the output: tests passed in green and failed in red and also supports to add more execution parameters in the settings.

ff82a035169738a148fe946c757ee8d1.gif

8. run-python-simply package

Run a python file in cmd or Powershell or other Linux terminals.

b8db74227c07197f8ae0626a9f54a3d4.png

Usage

  1. Open a .py file.
  2. Press F5 to run.

Features

  • cmd or Powershell
  • Two options for you, cmd and powershell. Choose one you like!
  • CodeBlocks debug console style
  • Show return value and execution time

Config The commands use {file} as a placeholder for the file to run. I redesign the commands format to support linux systems in the future. Now Windows cmd and powershell are available.

b1a8bc19624c99c87653551f448bf160.png

9. python-indent

Python Indent is the indentation behavior you've been waiting for in Atom! You should no longer have to worry about mashing your tab/space/backspace key every time you press enter in the middle of coding. Also, compared to other editors, there is no need to change an app configuration if you want to have a mixture of different types of indents (namely hanging and opening-delimiter-aligned).

The main obstacle with Atom's native indentation behavior is that it doesn't yet have the necessary API's to do what Python's PEP8 style guide suggests. Enhancement requests and issues have been opened in Atom Core on a few occasions, but none have been resolved yet.

This package was made to give you expected indentation behavior; python-indent listens for editor:newlineevents in Python source files, and when triggered, adjusts the indentation to be lined up relative to the opening delimiter of the statement or "hanging" (for parameters, tuples, or lists).

Indent Types Both indent types for continuing lines as described in PEP 0008 -- Style Guide for Python Code are auto-detected and applied by this package.

  • Aligned with Opening Delimiter
    def function_with_lots_of_params(param_1, param_2,
                                   param_3, param_4,
                                   very_long_parameter_name,
                                   param_6)
    def function_with_lots_of_params(
        param_1, param_2,
        param_3, param_4,
        very_long_parameter_name,
        param_6)
  • Setting*
  • Hanging Indent Tabs: Number of tabs used for hanging indents

Examples

def current_language_python_package(first_parameter, second_parameter,#<newline>
third_parameter):#<---default Atom language-python
    pass

def with_python_indent_package_added(first_parameter, second_parameter,
                                     third_parameter):
    #<--properly dedents to here
    pass

def with_hanging_indent(
    first_parameter, second_parameter, third_parameter):
    pass

also_works_with_lists = ["apples", "oranges", "pears", "peaches", "mangoes",
                         "clementines", "etc."]#<--PEP8 continued indentation
or_like_this = [
    "apples", "oranges", "pears",
    "peaches", "mangoes", "clementines",
    "etc."
]

10. python-mrigor package

Integration of mr.igor in atom!

mr.igor is an extension to pyflakes that will learn where you import things from, and then automatically fill in missing imports from the place they are most often imported.

This package integrates mr.igor in your atom editor. Just install mr.igor in your system (pip install mr.igor), and then install this package in atom.

Whenever you save a python file, mr.igor will save all imports, so that you can remember them in any other python file just pushing ctrl-alt-i

11. Python-Debugger package

Keyboard Shortcuts

  • alt-r/option-r: hide/show the debugger view
  • alt-shift-r/option-shift-r: toggle breakpoint at the current line

How to use

  1. Install using APM $ apm install python-debugger language-python The language-pythonpackage provides syntax highlighting
  2. Open the Python file to debug and insert breakpoints
  3. Press alt-r to show the debugger view
  4. Insert input arguments in the input arguments field if applicable
  5. Hit the Run button. Focus moves to the first breakpoint.
  6. Use the buttons provided to navigate through your source. You can enter debugger commands directly in the command field.

The current version should support Python 2.5 and higher, including Python 3. The Python executable to be used while debugging can be changed in the settings.

da470c7dfcb816143db760f7b01bf2df.gif

12. python-docstring

Add a simple docstring to your Python code.

Docstring Example

def my_function():
    """Do nothing, but document it.

    No, really, it doesn't do anything.
    """
    pass

13. aligner-python

Aligner add-on to support Python. Supported operators ::

colors = {
    "red":    "ff0000",
    "blue":   "0000ff",
    "yellow": "ffff00"
}

=: assignment

someArray = [0, 1]
zero      = 0

14. Python Snippets for Atom

Install : apm install python-snippets Features

  • Some important python 3.0 snippets of regular usage.

  • Also includes tkinter snippets for gui-programming in python.

  • Snippets list* The tkinter snippets assume that you have imported tkinter as tk import tkinter as tk

       #  Normal missing Functionality
    
     'def'
       'body': '''
       def ${1:fname}(${2:arg}):
           ${3:pass}
       '''
     'defi'
       'body': '''
       def __init__(self, ${1:arg}):
           ${2:pass}
       '''
     'print'
       'body': 'print($1)'
    
    
# tkinter snippets

'button' 'body': 'tk.Button(${1:root}, text="$2")'

'label' 'body': 'tk.Label(${1:root}, text="$2")'

'frame' 'body': 'tk.Frame(${1:root})'

'entry' 'body': 'tk.Entry(${1:root})'

'grid' 'body': 'grid(row=$1, colomn=$2)'

'sticky' 'body': 'sticky=tk.$1'

'checkbutton' 'body': 'tk.Checkbutton(${1:root}, text="$2")'

'mainloop' 'body': 'mainloop()'


## 15. [Python DocBlock Package](https://atom.io/packages/docblock-python)

DocBlock is the package for [Atom](https://atom.io/) which helps you to document your python code.

![76951be9f86b8b688c72d41f556b3fec.gif](https://i.gyazo.com/76951be9f86b8b688c72d41f556b3fec.gif)

**Instalation**
From the command line run apm install docblock-python..

## 16. [Python Nosetests](https://atom.io/packages/python-nosetests)

![fd548caf519bc7d1abe242f2fcbfa251.png](https://i.gyazo.com/fd548caf519bc7d1abe242f2fcbfa251.png)

**Installation**

sudo pip install nose nosetests-json-extended

**Usage**
When running nosetests for the first time on a project, go to the project root and run the tests from the command line:

(python2) nosetests --with-json-extended (python3) python3 -m nose --with-json-extended

This will generate a file nosetests.json which contains, besides the test results, also the required information to re-run the tests.

In the Atom editor, open a file that belongs to the project and go to:

`Menu -> Packages -> Python Nosetests -> Run   (Or press F5)`
The Python Nosetests package will now locate the nosetests.json file, run the tests again and show the results.

## 17. [Python line profiler for Atom](https://atom.io/packages/python-line-profiler)

![42411e22d4354660bb3bd3dc35c6c73a.png](https://i.gyazo.com/42411e22d4354660bb3bd3dc35c6c73a.png)

**Requirements**
* Mac OS, or Linux machine (this is not  on windows machine)
* A [line_profiler](https://github.com/iddl/line_profiler) fork is needed to run this extension.

pip install https://github.com/iddl/line_profiler/zipball/master

**How to run**
1) Make sure you're using the right environment. This is done by modifying the 'Shell command' option in the settings.

Shell command Default: /usr/bin/python

The default, /usr/bin/python, works for small tests. However it might be the case you're using virtualenvs and/or running code from a virtual machine.

Example setting of running profiler from a virtual environment in a VM.

`ssh, vagrant@192.168.34.10, -t, /home/user/project/venv/bin/python`

2) ALT+SHIFT+P to activate
This will show an editor with a Run button.

3) Import the function to profile first. The profiler is executed from the parent directory of the profiled code (this doesn't matter if you choose a custom shell command).
Use the profile function to run a profile on your code.
The end product should look something like

from test import myfunction profile(myfunction, myargs) ```

18. Flag as spam or malicious

python-suite package This package aims to makes atom an even more Python friendly place. Features:

  • Outliner/Navigator More coming soon!
  • Dependencies:*
  • python3
  • jedi

19. Python Isort for Atom editor

Install Make sure you have Isort installed and the correct path to binary was set in the package config.

Keymap Currently, there are two following commands:

  • python-isort:sortImports - for sorting imports

20. python-jedi package

Python Jedi based autocompletion plugin. Features

  • Autocomplete.
  • Goto Definition.
  • Installation*
  • Either use Atoms package manager or apm install python-jedi. Install autocomplete-plus before installing this package.
  • Usage*
  • python-jedi uses python3 interpreter in your path by default.(i.e., by default Pathtopython field holds value python3).
  • Enter the path to python executable in the settings(Pathtopython field) (eg:/home/user/py3pyenv/bin/python3 or /home/user/py2virtualenv/bin/python).
  • To Use Goto Definition*
  • Use the keyboard shortcut ctrl-alt-j.

This post is curated by IssueHunt that an issue based bounty for open-source projects.

https://issuehunt.io/

issuehunt-image