Skip to main content

PEP8 clean only the parts of the files which you have touched since the last commit, previous commit or branch.

Project description

pep8radius

PEP8 clean only the parts of the files touched since the last commit, a previous commit or branch.

Current PyPi Version MIT licensed Travis CI Status Coverage Status PyPi Monthly Downloads

Fixing the entire project of PEP8 infractions (“PEP8 storms”) can lead to merge conflicts, add noise to merges / pull requests and break (git) blame. pep8radius solves this problem by fixing only those PEP8 infractions incontained on the lines of the project which you’ve been working, leaving these sections “better than you found it” whilst keeping your commits focused on the areas of the codebase you were actually working on.

Installation

From pip:

$ pip install pep8radius

Usage

Usage gif of pep8radius
  • Move to project directory

  • Make some changes to the project

  • Run pep8radius --diff # view a diff of proposed fixed

  • Run pep8radius --in-place # apply the fixes

  • Commit your changes

Against a branch you can use the same syntax as with git diff:

$ pep8radius master   # branch name to compare against (compares against merge-base)
$ pep8radius c12166f  # commit hash

$ pep8radius master --in-place  # these work with other options too

You can also fix docstrings (PEP257) using the docformatter option:

$ pep8radius --docformatter --diff

Note: can also use ``btyfi`` alias for ``pep8radius``.


It can be nice to pipe the diff to cdiff (which makes diffs pretty and has lots of options):

$ pep8radius --diff --no-color | cdiff
$ pep8radius --diff --no-color | cdiff --side-by-side

You can get strange results if you don’t use no-color. I actually use the following git alias (which allows git rad and git rad -i):

[alias]
    rad = !pep8radius master --diff --no-color $@ | cdiff --side-by-side
git rad

Requirements

pep8radius uses autopep8, and in turn pep8. The docformatter option, to fix docstrings, uses docformatter.

VCS Support

Git, Mecurial (hg), (tentatively) Bazaar. Please request support for other version control systems on github.

Options

usage: pep8radius.py [-h] [--version] [-v] [-d] [-i] [-p n] [-a]
                     [--experimental] [--exclude globs] [--list-fixes]
                     [--ignore errors] [--select errors] [--max-line-length n]
                     [--indent-size n] [--docformatter] [--no-blank]
                     [--pre-summary-newline] [--force-wrap]
                     [rev]

positional arguments:
  rev                   commit or name of branch to compare against

optional arguments:
  -h, --help            show this help message and exit
  --version             print version number and exit
  -v, --verbose         print verbose messages; multiple -v result in more
                        verbose messages (passed to autopep8)
  -d, --diff            print the diff for the fixed source
  -i, --in-place        make the changes in place
  -f, --docformatter    fix docstrings for PEP257 using docformatter
  -p n, --pep8-passes n
                        maximum number of additional pep8 passes (default:
                        infinite)
  -a, --aggressive      enable non-whitespace changes; multiple -a result in
                        more aggressive changes
  --experimental        enable experimental fixes
  --exclude globs       exclude file/directory names that match these comma-
                        separated globs
  --list-fixes          list codes for fixes; used by --ignore and --select
  --ignore errors       do not fix these errors/warnings (default: E24)
  --select errors       fix only these errors/warnings (e.g. E4,W)
  --max-line-length n   set maximum allowed line length (default: 79)
  --indent-size n       number of spaces per indent level (default 4)
  --no-blank            do not add blank line after description; used by
                        docformatter
  --pre-summary-newline
                        add a newline before the summary of a multi-line
                        docstring; used by docformatter
  --force-wrap          force descriptions to be wrapped even if it may result
                        in a mess; used by docformatter

For more information about these options see `autopep8 <https://pypi.python.org/pypi/autopep8>`__.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pep8radius-0.8.2.tar.gz (16.6 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page