pre-commitpre-commit.com

Why is pre-comit run --all-files -v is not checking Python files


This is my .pre-commit-config.yaml

repos:
-   repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v3.2.0
    hooks:
    -   id: fix-encoding-pragma
    -   id: check-ast

In same directotry I have

$ tree
.
├── LICENSE
├── README.md
└── main.py

When I run pre-commit run --all-files -v, from same directory, I get:

$ pre-commit run --all-files -v
Fix python encoding pragma...........................(no files to check)Skipped
- hook id: fix-encoding-pragma
Check python ast.....................................(no files to check)Skipped
- hook id: check-ast

I do not understand why file main.py is not checked ?
This is my first time using pre-commit.


Solution

  • your main.py has not been git added -- that is: it is not part of the repository

    pre-commit only runs on files which are part of the repository


    disclaimer: I wrote pre-commit