Search code examples
djangopep8autopep8

Run autopep8 on all python files except migrations doable?


Am wondering is there a way to run autopep8 command on all python files exept the migrations? To fix all pep8 errors.

Instead of doing the command

autopep8 --in-place --aggressive --aggressive <filename>

Solution

  • You can let find first look for files and then use autopep8 on these:

    find -type f -name '*.py' ! -path '*/migrations/*' -exec autopep8 --in-place --aggressive --aggressive '{}' \;

    Here find thus looks for files that match the *.py glob pattern, but do not satisfy the */migrations/* pattern for its path.