Enforce the same settings across multiple language-independent projects
Project description
Nitpick
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.
The CLI now has a nitpick fix command that modifies configuration files directly
(pretty much like black and isort do with Python files).
See the CLI documentation for more info.
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.group.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
setup.cfg; - ... Pylint is present as a
Poetry dev dependency in
pyproject.toml.
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
nitpick fixcommand); - Others are still under construction; the ticket numbers are shown in the table (upvote the ticket with 👍🏻 if you would like to prioritise development).
Implemented
| File type | nitpick check |
nitpick fix |
|---|---|---|
| Any INI file | ✅ | ✅ |
| Any JSON file | ✅ | ✅ |
| Any plain text file | ✅ | ❌ |
| Any TOML file | ✅ | ✅ |
| Any YAML file | ✅ | ✅ |
| .editorconfig | ✅ | ✅ |
| .pylintrc | ✅ | ✅ |
| setup.cfg | ✅ | ✅ |
Planned
| File type | nitpick check |
nitpick fix |
|---|---|---|
| Any Markdown file | #280 🚧 | ❓ |
| Any Terraform file | #318 🚧 | ❓ |
| Dockerfile | #272 🚧 | #272 🚧 |
| .dockerignore | #8 🚧 | #8 🚧 |
| .gitignore | #8 🚧 | #8 🚧 |
| Jenkinsfile | #278 🚧 | ❓ |
| Makefile | #277 🚧 | ❓ |
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:
any
javascript
| Style URL | Description |
|---|---|
| py://nitpick/resources/javascript/package-json | package.json |
kotlin
| Style URL | Description |
|---|---|
| py://nitpick/resources/kotlin/ktlint | ktlint |
markdown
| Style URL | Description |
|---|---|
| py://nitpick/resources/markdown/markdownlint | Markdown lint |
presets
| Style URL | Description |
|---|---|
| py://nitpick/resources/presets/nitpick | Default style file for Nitpick |
proto
| Style URL | Description |
|---|---|
| py://nitpick/resources/proto/protolint | protolint (Protobuf linter) |
python
shell
toml
| Style URL | Description |
|---|---|
| py://nitpick/resources/toml/toml-sort | TOML sort |
Quickstart
Install
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 the latest release with Homebrew:
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 uv:
uv add --dev nitpick
Add to your project with Poetry:
poetry add --dev nitpick
Or install it with pip:
pip install -U nitpick
Run
Nitpick will fail if no style is explicitly configured. Run this command to download and use the opinionated default style file:
nitpick init
You can use it as a template to configure your own style.
To fix and modify your files directly:
nitpick fix
To check for errors only:
nitpick check
Nitpick is also a flake8 plugin, so
you can run this on a project with at least one Python (.py) file:
flake8 .
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:
There are a few hook IDs available.
The recommendation is to choose nitpick-suggest and one of the fix/check hooks.
repos:
- repo: https://github.com/andreoliwa/nitpick
rev: v0.38.1
hooks:
# This hook runs the `nitpick init --fix --suggest` command
- id: nitpick-suggest
# Choose only one of the "fix" or "check" hooks.
# These hooks run the `nitpick fix` command
- id: nitpick
# - id: nitpick-fix-all # same as nitpick
# - id: nitpick-fix
# These hooks run the `nitpick check` command
# - id: nitpick-check-all
# - id: nitpick-check
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]
To install the pre-commit and commit-msg Git hooks
using prek (pre-commit re-engineered in Rust):
prek install --install-hooks
prek install -t commit-msg
To start checking all your code against the default rules:
prek run --all-files
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.38.1/mega-linter-plugin-nitpick/nitpick.megalinter-descriptor.yml
ENABLE_LINTERS:
- NITPICK
More information
Nitpick is being used by projects such as:
For more details on styles and which configuration files are currently supported, see the full documentation.
Contributing
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nitpick-0.38.1.tar.gz.
File metadata
- Download URL: nitpick-0.38.1.tar.gz
- Upload date:
- Size: 292.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.13 {"installer":{"name":"uv","version":"0.9.13"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a31b2a1f5b526f59eaded4a3fb03c69150d1692846816754516404c86269606c
|
|
| MD5 |
5723c62b7af40fb343051193f3a18a60
|
|
| BLAKE2b-256 |
483ea95144d7fb6703fc4f51695a3f5c054dd843bebf562f20cecb772f970cda
|
File details
Details for the file nitpick-0.38.1-py3-none-any.whl.
File metadata
- Download URL: nitpick-0.38.1-py3-none-any.whl
- Upload date:
- Size: 80.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.13 {"installer":{"name":"uv","version":"0.9.13"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
048503d4d8d2494983182b92ac34d9053aa6bdbb6c827409bb62e40fd3c637e6
|
|
| MD5 |
cf26524142b6d4778552920a8e53cc27
|
|
| BLAKE2b-256 |
a381b307a00c31bef1433be5f5e66a149700b6edffa70a3c2632475601e97501
|