Try running Nitpick with the new Command-line interface instead of a flake8 plugin.
In the future, there are plans to make flake8 an optional dependency.
Flake8 lints Python files; Nitpick “lints” configuration (text) files instead.
To act like a flake8 plugin, Nitpick does the following:
Use the first Python file found and ignore other Python files in the project.
Check the style file and compare with the configuration/text files.
Report violations on behalf of that Python file, and not on the configuration file that’s actually wrong.
So, if you have a violation on
setup.cfg, it will be reported like this:
./tasks.py:0:1: NIP323 File setup.cfg: [flake8]max-line-length is 80 but it should be like this: [flake8] max-line-length = 120
tasks.py at the beginning of the line, and not
To run Nitpick as a Flake8 plugin, the project must have at least one Python file*.
If your project is not a Python project, creating a
dummy.py file on the root of the project is enough.
Pre-commit hook and flake8¶
This current default pre-commit hook (called
nitpick) is a placeholder for the future, when flake8 will be only an optional dependency.
This in intentional, because Nitpick is not a conventional flake8 plugin.
Since flake8 only lints Python files, the pre-commit hook will only run when a Python file is modified. It won’t run when a config/text changes.
An example: suppose you’re using a remote Nitpick style (like the style from WeMake).
At the moment, their style currently checks
Suppose they change or add an option on their isort.toml file.
If the nitpick pre-commit hook had
always_run: false and
pass_filenames: true, your local
setup.cfg would only be verified:
If a Python file was changed.
If you ran
pre-commit run --all-files.
So basically the pre-commit hook would be useless to guarantee that your config files would always match the remote style… which is precisely the purpose of Nitpick.
To avoid this, use the other pre-commit hooks, the ones that call the Nitpick CLI directly instead of running
Root dir of the project¶
Nitpick tries to find the root dir of the project using some hardcoded assumptions.
Starting from the current working directory, it will search for files that are usually in the root of a project:
Main Python file¶
Those are the Python files that are considered: