Unable to exclude directory with yapf

2.9k Views Asked by At

I'm unable to exclude a directory from being autoformatted with yapf.

Tested usages:

yapf --in-place --recursive --parallel --exclude 'somedir' --exclude '*_pb2.py' .
yapf --in-place --recursive --parallel --exclude 'somedir/*' --exclude '*_pb2.py' .
yapf --in-place --recursive --parallel --exclude 'somedir/**' --exclude '*_pb2.py' .

It seems to take file patterns well but not folder patterns.

  • yapf version: 0.21.0
  • OS: Ubuntu 14.04 LTS
  • python version: 2.7 (in a virtualenv)
1

There are 1 best solutions below

0
On

Did you try yapf --in-place --recursive --parallel --exclude 'somedir/**/*.py' --exclude '**/*_pb2.py' .?

yapf uses fnmatch.fnmatch(path, exclude_pattern) under the hood.