Command-line tool and flake8 plugin to enforce the same settings across multiple language-independent projects.
Useful if you maintain multiple projects and are tired of copying/pasting the same INI/TOML/YAML/JSON keys and values over and over, in all of them.
Many more features are planned for the future, check the roadmap.
The style file
A "Nitpick code style" is a TOML file with the settings that should be present in config files from other tools.
Example of a style:
["pyproject.toml".tool.black] line-length = 120 ["pyproject.toml".tool.poetry.dev-dependencies] pylint = "*" ["setup.cfg".flake8] ignore = "D107,D202,D203,D401" max-line-length = 120 inline-quotes = "double" ["setup.cfg".isort] line_length = 120 multi_line_output = 3 include_trailing_comma = true force_grid_wrap = 0 combine_as_imports = true
This style will assert that:
- ... black, isort and flake8 have a line length of 120;
- ... flake8 and
isort are configured as above in
- ... Pylint is present as a
Poetry dev dependency
Supported file types
These are the file types currently handled by Nitpick.
- Some files are only being checked and have to be modified manually;
- Some files can already be fixed automatically (with the
- Others are still under construction; the ticket numbers are shown in the table (upvote the ticket with 👍🏻 if you would like to prioritise development).
|Any INI file|
|Any JSON file|
|Any plain text file|
|Any TOML file|
|Any YAML file|
|Any Markdown file||#280
|Any Terraform file||#318
Style Library (Presets)
Nitpick has a builtin library of style presets, shipped as Python resources.
This library contains building blocks for your your custom style. Just choose styles from the table below and create your own style, like LEGO.
Read how to:
|py://nitpick/resources/presets/nitpick||Default style file for Nitpick|
|py://nitpick/resources/proto/protolint||protolint (Protobuf linter)|
|py://nitpick/resources/shell/bashate||bashate (code style for Bash)|
|py://nitpick/resources/shell/shellcheck||ShellCheck (static analysis for shell scripts)|
|py://nitpick/resources/shell/shfmt||shfmt (shell script formatter)|
Install in an isolated global environment with pipx:
# Latest PyPI release pipx install nitpick # Development branch from GitHub pipx install git+https://github.com/andreoliwa/nitpick
On macOS/Linux, install with Homebrew:
# Latest PyPI release brew install andreoliwa/formulae/nitpick # Development branch from GitHub brew install andreoliwa/formulae/nitpick --HEAD
On Arch Linux, install with yay:
yay -Syu nitpick
Add to your project with Poetry:
poetry add --dev nitpick
Or install it with pip:
pip install -U nitpick
To fix and modify your files directly:
To check for errors only:
Nitpick is also a
flake8 plugin, so you can run this on a project
with at least one Python (
Nitpick will download and use the opinionated default style file.
You can use it as a template to configure your own style.
Run as a pre-commit hook
If you use pre-commit on your project, add
this to the
.pre-commit-config.yaml in your repository:
repos: - repo: https://github.com/andreoliwa/nitpick rev: v0.32.0 hooks: - id: nitpick
There are 3 available hook IDs:
nitpick-fixboth run the
If you want to run Nitpick as a flake8 plugin instead:
repos: - repo: https://github.com/PyCQA/flake8 rev: 4.0.1 hooks: - id: flake8 additional_dependencies: [nitpick]
Run as a MegaLinter plugin
If you use MegaLinter you can run Nitpick as a plugin. Add the following two entries to your
.mega-linter.yml configuration file:
PLUGINS: - https://raw.githubusercontent.com/andreoliwa/nitpick/v0.32.0/mega-linter-plugin-nitpick/nitpick.megalinter-descriptor.yml ENABLE_LINTERS: - NITPICK
Nitpick is being used by projects such as:
For more details on styles and which configuration files are currently supported, see the full documentation.
Your help is very much appreciated.
There are many possibilities for new features in this project, and not enough time or hands to work on them.
If you want to contribute with the project, set up your development environment following the steps on the contribution guidelines and send your pull request.