freshcrate
Home > Frameworks > autopep8

autopep8

A tool that automatically formats Python code to conform to the PEP 8 style guide

Description

======== autopep8 ======== .. image:: https://img.shields.io/pypi/v/autopep8.svg :target: https://pypi.org/project/autopep8/ :alt: PyPI Version .. image:: https://github.com/hhatto/autopep8/workflows/Python%20package/badge.svg :target: https://github.com/hhatto/autopep8/actions :alt: Build status .. image:: https://codecov.io/gh/hhatto/autopep8/branch/main/graph/badge.svg :target: https://codecov.io/gh/hhatto/autopep8 :alt: Code Coverage autopep8 automatically formats Python code to conform to the `PEP 8`_ style guide. It uses the pycodestyle_ utility to determine what parts of the code needs to be formatted. autopep8 is capable of fixing most of the formatting issues_ that can be reported by pycodestyle. .. _PEP 8: https://www.python.org/dev/peps/pep-0008/ .. _issues: https://pycodestyle.readthedocs.org/en/latest/intro.html#error-codes .. contents:: Installation ============ From pip:: $ pip install --upgrade autopep8 Consider using the ``--user`` option_. .. _option: https://pip.pypa.io/en/latest/user_guide/#user-installs Requirements ============ autopep8 requires pycodestyle_. .. _pycodestyle: https://github.com/PyCQA/pycodestyle Usage ===== To modify a file in place (with aggressive level 2):: $ autopep8 --in-place --aggressive --aggressive <filename> Before running autopep8. .. code-block:: python import math, sys; def example1(): ####This is a long comment. This should be wrapped to fit within 72 characters. some_tuple=( 1,2, 3,'a' ); some_variable={'long':'Long code lines should be wrapped within 79 characters.', 'other':[math.pi, 100,200,300,9876543210,'This is a long string that goes on'], 'more':{'inner':'This whole logical line should be wrapped.',some_tuple:[1, 20,300,40000,500000000,60000000000000000]}} return (some_tuple, some_variable) def example2(): return {'has_key() is deprecated':True}.has_key({'f':2}.has_key('')); class Example3( object ): def __init__ ( self, bar ): #Comments should have a space after the hash. if bar : bar+=1; bar=bar* bar ; return bar else: some_string = """ Indentation in multiline strings should not be touched. Only actual code should be reindented. """ return (sys.path, some_string) After running autopep8. .. code-block:: python import math import sys def example1(): # This is a long comment. This should be wrapped to fit within 72 # characters. some_tuple = (1, 2, 3, 'a') some_variable = { 'long': 'Long code lines should be wrapped within 79 characters.', 'other': [ math.pi, 100, 200, 300, 9876543210, 'This is a long string that goes on'], 'more': { 'inner': 'This whole logical line should be wrapped.', some_tuple: [ 1, 20, 300, 40000, 500000000, 60000000000000000]}} return (some_tuple, some_variable) def example2(): return ('' in {'f': 2}) in {'has_key() is deprecated': True} class Example3(object): def __init__(self, bar): # Comments should have a space after the hash. if bar: bar += 1 bar = bar * bar return bar else: some_string = """ Indentation in multiline strings should not be touched. Only actual code should be reindented. """ return (sys.path, some_string) Options:: usage: autopep8 [-h] [--version] [-v] [-d] [-i] [--global-config filename] [--ignore-local-config] [-r] [-j n] [-p n] [-a] [--experimental] [--exclude globs] [--list-fixes] [--ignore errors] [--select errors] [--max-line-length n] [--line-range line line] [--hang-closing] [--exit-code] [files [files ...]] Automatically formats Python code to conform to the PEP 8 style guide. positional arguments: files files to format or '-' for standard in optional arguments: -h, --help show this help message and exit --version show program's version number and exit -v, --verbose print verbose messages; multiple -v result in more verbose messages -d, --diff print the diff for the fixed source -i, --in-place make changes to files in place --global-config filename path to a global pep8 config file; if this file does not exist then this is ignored (default:

Release History

VersionChangesUrgencyDate
2.3.2Imported from PyPI (2.3.2)Low4/21/2026
v2.3.2## What's Changed * Update README.rst: Typo fix by @mrichtarsky in https://github.com/hhatto/autopep8/pull/768 * Bump codecov/codecov-action from 4 to 5 by @dependabot in https://github.com/hhatto/autopep8/pull/773 * support Python 3.13 and drop 3.8 by @hhatto in https://github.com/hhatto/autopep8/pull/777 * Fix E721 type comparison pattern handling by @hhatto in https://github.com/hhatto/autopep8/pull/776 ## New Contributors * @mrichtarsky made their first contribution in https://githubLow1/14/2025
v2.3.1## What's Changed ### Bug Fix * skip e501 fixed method for f-string line without aggressive option by @hhatto in https://github.com/hhatto/autopep8/pull/754 * Fix argument parser errors are printed without a trailing newline by @hhatto in https://github.com/hhatto/autopep8/pull/758 ### Enhancement * Refactor unit test by @hhatto in https://github.com/hhatto/autopep8/pull/756 * Remove coveralls by @hhatto in https://github.com/hhatto/autopep8/pull/757 * codecov with 3.11 and 3.12 by @hLow6/23/2024
v2.3.0## What's Changed * add handling for E204 whitespace after decorator by @asottile in https://github.com/hhatto/autopep8/pull/752 * require to pycodestyle v2.12.0+ **Full Changelog**: https://github.com/hhatto/autopep8/compare/v2.2.0...v2.3.0Low6/16/2024
v2.2.0## What's Changed ### Other * experimental option is deprecated by @hhatto in https://github.com/hhatto/autopep8/pull/749 ### Bug Fixes * fix specific case of e271 and w504 by @hhatto in https://github.com/hhatto/autopep8/pull/748 * skip e501 fixed method for f-string line(s) by @hhatto in https://github.com/hhatto/autopep8/pull/750 **Full Changelog**: https://github.com/hhatto/autopep8/compare/v2.1.2...v2.2.0Low5/30/2024
v2.1.2## What's Changed * Fix e501 experimental fstring case in Python3.12+ by @hhatto in https://github.com/hhatto/autopep8/pull/747 **Full Changelog**: https://github.com/hhatto/autopep8/compare/v2.1.1...v2.1.2Low5/28/2024
v2.1.1## What's Changed * force reload pycodestyle module by @hhatto in https://github.com/hhatto/autopep8/pull/740 * include test/acid.py in sdist package by @hhatto in https://github.com/hhatto/autopep8/pull/741 **Full Changelog**: https://github.com/hhatto/autopep8/compare/v2.1.0...v2.1.1Low5/22/2024
v2.1.0## What's Changed * migrate to pyproject.toml by @hhatto in https://github.com/hhatto/autopep8/pull/705 * Revert "Update MANIFEST.in" by @hhatto in https://github.com/hhatto/autopep8/pull/710 * run with pypy3.10 by @hhatto in https://github.com/hhatto/autopep8/pull/711 * ISSUE_TEMPLATE: use "console" instead of non-existing "shell" syntax by @emanuele6 in https://github.com/hhatto/autopep8/pull/714 * add 3.12, drop 3.7 by @hhatto in https://github.com/hhatto/autopep8/pull/709 * tox: add pyLow3/17/2024
v2.0.4## What's Changed * Paugier fix pycodestyle missing whitespace by @hhatto in https://github.com/hhatto/autopep8/pull/704 * Try to fix an AttributeError related to pycodestyle 2.11.0 by @paugier in https://github.com/hhatto/autopep8/pull/699 ## New Contributors * @paugier made their first contribution in https://github.com/hhatto/autopep8/pull/699 **Full Changelog**: https://github.com/hhatto/autopep8/compare/v2.0.3...v2.0.4Low8/26/2023
v2.0.3## What's Changed * add pre-commit configuration by @asottile in https://github.com/hhatto/autopep8/pull/679 * Add pre commit config by @hhatto in https://github.com/hhatto/autopep8/pull/681 * Version dependent operator whitespace function. by @keriksson-rosenqvist in https://github.com/hhatto/autopep8/pull/696 * Update MANIFEST.in by @keriksson-rosenqvist in https://github.com/hhatto/autopep8/pull/693 ## New Contributors * @keriksson-rosenqvist made their first contribution in https://gLow8/25/2023
v2.0.2## What's Changed * Ignore DeprecationWarnings to fix tests on py3.11 by @mgorny in https://github.com/hhatto/autopep8/pull/665 * fix: infinite loop in autopep8.fix_code without w50 ignore option by @hhatto in https://github.com/hhatto/autopep8/pull/677 **Full Changelog**: https://github.com/hhatto/autopep8/compare/v2.0.1...v2.0.2Low3/3/2023
v2.0.1## What's Changed * Add 'python_requires=">=3.6"' to match tomli package by @vphilippon in https://github.com/hhatto/autopep8/pull/656 * require pycodestyle 2.10.0 and higher version by @hhatto in https://github.com/hhatto/autopep8/pull/659 * update actions by @hhatto in https://github.com/hhatto/autopep8/pull/658 * Support using built-in tomllib in Python 3.11 by @mgorny in https://github.com/hhatto/autopep8/pull/654 * fix: e265, e266 by @hhatto in https://github.com/hhatto/autopep8/pull/6Low12/15/2022
v2.0.0version 1.7.1 is yanked. release version 2.0.0Low10/28/2022
v1.7.1## What's Changed * Cleanup Python 2 references in setup.py by @geozeke in https://github.com/hhatto/autopep8/pull/644 * include tox.ini (because need unit test) by @hhatto in https://github.com/hhatto/autopep8/pull/646 * Fix E265 and E266 confusion and overlap by @PeterJCLaw in https://github.com/hhatto/autopep8/pull/650 * Use tomli in place of unmaintained toml package by @mgorny in https://github.com/hhatto/autopep8/pull/629 * fix: special case of `auto` value with flake8 config by @hhaLow10/28/2022
v1.7.0## Change * Require [pycodestyle](https://pypi.org/project/pycodestyle/) 2.9.1 and higher version ( Thanks @heavenshell ⭐ ) * Drop support Python2.7 ## New Feature * Support E275 ## Bug Fix * Ignoring W191 ( Thanks @MinekPo1 ⭐ ) --- ## What's Changed * add: verbose log for reading config paths by @hhatto in https://github.com/hhatto/autopep8/pull/622 * Document being able to turn formatting off by @shardros in https://github.com/hhatto/autopep8/pull/620 * Add support for ignorLow8/9/2022
v1.6.0## Change * required [pycodestyle](https://pypi.org/project/pycodestyle/) version 2.8.0 and higher version ( Thanks @heavenshell ) ## Buf Fix * #607 , #608 : Ignore Settings for W292 Do Not Work * #603 , #604 : Multiple #autopep8: off/on directives in one file do not work ( Thanks @SPKorhonen ) * #612 , #618 : `--hang-closing` option does not work for non-indented linesLow10/24/2021
v1.5.7## Change * #597: disallow 0 for indent-size option * #595: exit code is 99 when error occured cli option parsing ## Bug Fix * #591, #592: exit code correctly on permission denied failureLow4/30/2021
v1.5.6## Update * [pycodestyle version 2.7.0](https://pycodestyle.pycqa.org/en/latest/developer.html#id2) and higher is now required (Thanks @heavenshell ) ## Bug Fix * #585 : E128 check similar to pycodestyle (Thanks @yamt )Low3/17/2021
v1.5.5bug fix and minor improvements * improvement * https://github.com/hhatto/autopep8/issues/566: lazy load `toml` package * fix bug * https://github.com/hhatto/autopep8/pull/580: not convert raw string for w605 fixed method Low2/4/2021
v1.5.4* new feature * Skip formatting of a block in a file * use with `fmt: on/off` or `autopep8: on/off` * related: #460, #557 (Thanks to @shardros) * fix bugs * #551, #553: ignoring W292 with --ignore option * #564, #565: ignore SyntaxWarning in Python3.8+ Low8/2/2020
v1.5.3* changes * requirement pycodestyle version 2.6.0+ ( #548 ) * fix bugs * Expected pyproject.toml configuration syntax incompatible with TOML format ( #528 , #546 ) * Fix incompatible exit code with --jobs=0 and --exit-code ( #543 , #545 ) * Fix hangup E122 fixed method with backslash ( #540 , #541 )Low5/31/2020
v1.5.2* new features * #480, #535 : support parallel jobs for diff option * changes * #501, #537 : enable exclude option when specify directly file args * fix bugs * #364, #538 : related code E702 * #533 : related code W503/W504Low4/20/2020
v1.5.1* fix bugs * #525 : related code W503 and W504 (Thanks @NovaDev94) * #526 : return diff exit code when reading from stdin too (Thanks @pvxe ) * #529, #530 : related code E402 * #518, #532 : related code W503 and W504Low4/6/2020
v1.5* Support Python3.8 * Support `pyproject.toml` with `[tool.autopep8]` section. * fix bugs * #503, #511 : related code W503 * #486, #488 : related code E117 * #489, #498 : related code E711/E712 * #449, #514 : related code W605Low1/20/2020
v1.4.4* fix bugs * #456, #466 : related code W504/3 (Thanks @asottile ) * #463, #464 : related code W504 (Thanks @bagerard ) * #461, #467 : related code E402 (Thanks @Hanaasagi ) * Improved * #457 : Don't write the file unless there are changes (Thanks @asottile ) * #478 : update configuration documentation (Thanks @Ch00k )Low4/14/2019
v1.4.3fix bugs * #449 (PR: #450) : related code W605 (Thanks to patch by @bigredengineer) * #447 : related code E402 * #446 : related code W503Low11/12/2018
v1.4.2* fix bugs * #441 : related code is W503 * #443 : related code is W503Low10/23/2018
v1.4* new feature: add W605 fixed method * new feature: add E252 fixed method (Thanks to patch by @gmbnomis) * change: W690 (only use autopep8) is DEFAULT_IGNORE. * fix bugs * #415, #399, #410, #392 * #386 (Thanks to patch by @Hnasar)Low9/1/2018
v1.3.5* load config value from flake8 section * fix bugs (#322, #389, #332, #388) * support Python version: 2.7+ or 3.4+Low3/30/2018
v1.3.4* new feature: add E133 fixed method and `--hang-closing` option * improved: E712 fixed method logic (#368) * fix bugs (#330, #331, #351, #353)Low1/24/2018
v1.3.3* fix bugs (#246, #323, #333, #338, #346) * improve verbose outputLow11/10/2017

Dependencies & License Audit

Loading dependencies...

Similar Packages

robotframeworkGeneric automation framework for acceptance testing and robotic process automation (RPA)7.4.2
seleniumbaseA complete web automation framework for end-to-end testing.4.48.2
pytest-base-urlpytest plugin for URL based testing2.1.0
pre-commitA framework for managing and maintaining multi-language pre-commit hooks.v4.6.0
azure-core-tracing-opentelemetryMicrosoft Azure Azure Core OpenTelemetry plugin Library for Pythonazure-template_0.1.0b6187637