• Spyder.autopep8 Description. This is a plugin to run the autopep8 python linter from within spyder editor. Spyder plugin support will be released with version 3.0 (Still in Beta). If you want to try out this plugin you need to use the latest development version o Spyder (master branch).
  • How to enable Python autopep8 in Atom EditorPlease Subscribe my Channel: T.

Line length¶

All Python code in this package should be PEP8 valid.This includes adhering to the 80-char line length.If you absolutely need to break this rule, append `` # noqa: E501`` to the offending line to skip it in syntax checks.

The python-autopep8 project's README file is empty or unavailable. Powered by Pagure 5.13.2 Documentation. File an Issue. About this Instance. SSH Hostkey/Fingerprint.


Configuring your editor to display a line at 79th column helps a lot here and saves time.


The line length rule also applies to non-Python source files, such as .zcml files, but is a bit more relaxed there.


The rule explicitly does not apply to documentation.rst files.For .rst files including the package documentation but also README.rst, CHANGES.rst, and doctests, add a line break after each sentence.See the :doc:` documentation styleguide </about/contributing/documentation_styleguide>` for more information.

Breaking lines¶

Based on code we love to look at (Pyramid, Requests, etc.), we allow the following two styles for breaking long lines into blocks:

  1. Break into next line with one additional indent block.

  2. If this still doesn’t fit the 80-char limit, break into multiple lines.

  • Arguments on first line, directly after the opening parenthesis are forbidden when breaking lines.

  • The last argument line needs to have a trailing comma (to be nice to the next developer coming in to add something as an argument and minimize VCS diffs in these cases).

  • The closing parenthesis or bracket needs to have the same indentation level as the first line.

  • Each line can only contain a single argument.

  • The same style applies to dicts, lists, return calls, etc.


Making old code pep8 compliant can be a lot of work.There is a tool that can automatically do some of this work for you: autopep8.This fixes various issues, for example fixing indentation to be a multiple of four.Just install it with pip and call it like this:

It is best to first run autopep8 in the default non aggressive mode, which means it only does whitespace changes.To run this recursively on the current directory, changing files in place:

Quickly check the changes and then commit them.

WARNING: be very careful when running this in a skins directory, if you run it there at all.It will make changes to the top of the file like this, which completely breaks the skin script:

With those safe changes out of the way, you can move on to a second, more aggresive round:

Check these changes more thoroughly.At the very least check if Plone can still start in the foreground and that there are no failures or errors in the tests.

Not all changes are always safe.You can ignore some checks:

This skips the following changes:

  • W690: Fix various deprecated code (via lib2to3). (Can be bad forPython 2.4.)

  • E721: Use isinstance() instead of comparing types directly.(There are uses of this in for example GenericSetup and plone.api that must not be fixed.)

  • E711: Fix comparison with None. (This can break SQLAlchemy code.)

You can check what would be changed by one specific code:

This nbextension reformats/prettifies code in notebook python code cells.

Under the hood, it uses a call to the current notebook kernel to reformat thecode.The conversion run by the kernel uses the python autopep8 package, and thus is compatible only with python kernels.

The nbextension provides

  • a toolbar button (configurable to be added or not)
  • a keyboard shortcut for reformatting the current code-cell (default shortcutis Alt-A, can also be configured not to add the keyboard shortcut).
  • a keyboard shortcut for reformatting the whole notebook (default shortcutis Alt-Shift-A, can also be configured not to add the keyboard shortcut).

Syntax needs to be correct, but the nbextension may be able to point out basicsyntax errors.

Autopep8 Config File


Of course, you must have the necessary kernel-specific package installed forthe prettifier call to work:



All options are provided by the KerneExecOnCells library - see theinternals section below for details.There are a few nbextension-wide options, configurable using thejupyter_nbextensions_configurator or by editing the notebook section configfile directly.The options are as follows:

  • autopep8.add_toolbar_button:Whether to add a toolbar button to transform the selected cell(s).Defaults to true.

  • autopep8.button_icon:A font-awesome class defining the icon used for the toolbar button and actions.See fontawesome for available icon classes.Defaults to fa-cog.

  • autopep8.button_label:Toolbar button label text. Also used in the actions’ help text.Defaults to Prettify(usingautopep8).

  • autopep8.register_hotkey:Whether to register hotkeys to transform the selected cell(s)/whole notebook.Defaults to true.

  • autopep8.hotkeys.process_all:Hotkey to use to transform all the code cells in the notebook.Defaults to Alt-Shift-A.

  • autopep8.hotkeys.process_selected:Hotkey to use to transform the selected cell(s).Defaults to Alt-A.

  • autopep8.show_alerts_for_errors:Whether to show alerts for errors in the kernel calls.Defaults to true.

  • autopep8.kernel_config_map_json:The value of this key is a string which can be parsed into a json objectgiving the config for each kernel language.

    The following give the per-kernel options of the parsed json, using thelanguage key python:

    • autopep8.kernel_config_map_json.python.library:String to execute in the kernel in order to load any necessary kernellibraries.
    • autopep8.kernel_config_map_json.python.replacements_json_to_kernel:a list of pairs of strings, used as arguments to javascript’sString.replace(from,to) to translate from a json string into a validrepresentation of the same string in the kernel language. Since jsonstrings are particularly simple, this can often (as with the pythonlanguage) be left as the default, an empty list.
    • autopep8.kernel_config_map_json.python.prefix andautopep8.kernel_config_map_json.python.postfix:Strings added as bookends to the kernel string (translated from the jsonstring using the replacements above) to make up the kernel prettifier callkernel’s prettifier libraries.
    • autopep8.kernel_config_map_json.python.trim_formatted_text:Whether to trim whitespace from the transformed cell text. Since jupytercells don’t usually have leading or trailing whitespace, the defaultbehaviour is to trim the transformed text, in order to prevent thetransform adding extra newlines at the end (a common behaviour for sourcefiles, where having a trailing newline is often considered good practice).

Stackoverflow Atom Autopep8 Formatter


Under the hood, this nbextension uses the KerneExecOnCells library, a sharedlibrary for creating Jupyter nbextensions which transform code cell text usingcalls to the active kernel.

Autopep8 Vs Yapf

See the shared README for the internal model used by the nbextension.

Run Autopep8


The project was forked by @kenkoooo from @jfbercher‘s code_prettify,retaining most of the code.

It has since been altered to use the KerneExecOnCells library, a sharedlibrary for creating Jupyter nbextensions which transform code cell text usingcalls to the active kernel.