One of the pre-commit hooks set up in the repo is yapf (.pre-commit-config.yaml):
repos:
# Note: the YAPF config is found in `.style.yapf` and `.yapfignore`
- repo: https://github.com/pre-commit/mirrors-yapf
rev: v0.29.0
hooks:
- id: yapf
Whenever I make changes to a file that is included in .yapfignore and run the pre-commit hook, the hook fails:
pre-commit run yapf
[WARNING] Unstaged files detected.
[INFO] Stashing unstaged files to ****************
yapf.....................................................................Failed
- hook id: yapf
- exit code: 1
yapf: Input filenames did not match any python files
Anyone know how to avoid yapf failing on the files included in the .yapfignore?
Ok so the cause of the problem is that yapf treats files that are in the
.yapfignoreas if they're files that don't exist so you'll get a:Error if you run yapf against any file in the
.yapfignorefile. To get around this problem inpre-commit, I added an existing python file not in.yapfignoreas an argument so yapf always has a file to run against.