talira

autopep8

Automatically reformats Python code to follow the PEP 8 style guide

open sourceMITfree

A command-line tool and Python module that rewrites Python code to conform to PEP 8. It uses pycodestyle to find what needs fixing and can fix most of the formatting issues pycodestyle reports, in place or as a diff, with aggressive levels for larger changes such as wrapping long lines. Editors call it as a formatter, including through Microsoft's autopep8 extension for VS Code. MIT licensed.

Problems it solves

  • make my Python code follow PEP 8 automatically
  • clean up messy Python formatting without changing what the code does
  • fix the style warnings pycodestyle reports

Features

  • fixes most pycodestyle (PEP 8) formatting issues
  • in-place edits or diffs
  • aggressive levels for larger changes
  • usable as a command or a Python module

Limitations

  • Requires pycodestyle1

Alternatives

The same job

These do what autopep8 does.

  1. Black The uncompromising Python code formatter: one deterministic style, no configuration debates
  2. Ruff An extremely fast Python linter and code formatter, written in Rust
  3. YAPF Configurable Python code formatter based on clang-format's algorithm

Compare autopep8 with the top 3