Skip to main content

Enforce the same settings across multiple language-independent projects

Project description

PyPI GitHub Actions Python Workflow Documentation Status Coveralls Maintainability Test Coverage Supported Python versions Project License Code style: black Renovate semantic-release pre-commit.ci status

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 docs for more info.

Many more features are planned for the future, check the roadmap.

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:

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 fix command);
  • 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 #358 🚧
Any text file
Any TOML file
.editorconfig
package.json #358 🚧
.pre-commit-config.yaml #282 🚧
.pylintrc
pyproject.toml
requirements.txt
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 🚧
.travis.yml #15 🚧 #15 🚧

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 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

Run

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 .

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.27.0
    hooks:
      - id: nitpick

There are 3 available hook IDs: nitpick, nitpick-fix, nitpick-check.

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for nitpick, version 0.27.0
Filename, size File type Python version Upload date Hashes
Filename, size nitpick-0.27.0-py3-none-any.whl (53.9 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size nitpick-0.27.0.tar.gz (44.3 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page