Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/andreoliwa/nitpick
Enforce the same settings on multiple projects
https://github.com/andreoliwa/nitpick
flake8 flake8-plugin isort linter mypy pylint python python3 styleguide
Last synced: 7 days ago
JSON representation
Enforce the same settings on multiple projects
- Host: GitHub
- URL: https://github.com/andreoliwa/nitpick
- Owner: andreoliwa
- License: mit
- Created: 2018-03-23T14:25:24.000Z (over 6 years ago)
- Default Branch: develop
- Last Pushed: 2024-11-11T21:31:53.000Z (about 1 month ago)
- Last Synced: 2024-11-16T09:20:34.642Z (26 days ago)
- Topics: flake8, flake8-plugin, isort, linter, mypy, pylint, python, python3, styleguide
- Language: Python
- Homepage: https://nitpick.readthedocs.io/
- Size: 2.6 MB
- Stars: 399
- Watchers: 5
- Forks: 25
- Open Issues: 51
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.rst
- Funding: .github/FUNDING.yml
- License: LICENSE
- Authors: AUTHORS.rst
Awesome Lists containing this project
- awesome-flake8-extensions - nitpick - Enforce the same lint configuration (flake8, isort, mypy, pylint) across multiple Python projects. (Tools)
- best-of-python-dev - GitHub - 38% open ยท โฑ๏ธ 28.05.2024): (Linters & Style Checkers)
- awesome-codemods - **nitpick** - Apply the same pre-defined settings across all your projects (Fix aggregators / Debian)
README
Nitpick
=======|PyPI|
|Supported Python versions|
|GitHub Actions Python Workflow|
|Documentation Status|
|Coveralls|
|Maintainability|
|Test Coverage|
|pre-commit|
|pre-commit.ci status|
|Project License|
|Code style: black|
|Renovate|
|semantic-release|
|FOSSA 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 `_.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:
.. code-block:: toml
["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 = trueThis 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 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
~~~~~~~~~~~.. auto-generated-start-implemented
.. list-table::
:header-rows: 1* - 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 `_
- โ
- โ
.. auto-generated-end-implementedPlanned
~~~~~~~.. auto-generated-start-planned
.. list-table::
:header-rows: 1* - 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 `_ ๐ง
- โ
.. auto-generated-end-plannedStyle 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:
- `...add multiple styles to the configuration file `_;
- `...include styles inside a style `_... auto-generated-start-style-library
any
~~~.. list-table::
:header-rows: 1* - Style URL
- Description
* - `py://nitpick/resources/any/codeclimate `_
- `CodeClimate `_
* - `py://nitpick/resources/any/commitizen `_
- `Commitizen (Python) `_
* - `py://nitpick/resources/any/commitlint `_
- `commitlint `_
* - `py://nitpick/resources/any/editorconfig `_
- `EditorConfig `_
* - `py://nitpick/resources/any/git-legal `_
- `Git.legal - CodeClimate Community Edition `_
* - `py://nitpick/resources/any/pre-commit-hooks `_
- `pre-commit hooks for any project `_
* - `py://nitpick/resources/any/prettier `_
- `Prettier `_javascript
~~~~~~~~~~.. list-table::
:header-rows: 1* - Style URL
- Description
* - `py://nitpick/resources/javascript/package-json `_
- `package.json `_kotlin
~~~~~~.. list-table::
:header-rows: 1* - Style URL
- Description
* - `py://nitpick/resources/kotlin/ktlint `_
- `ktlint `_markdown
~~~~~~~~.. list-table::
:header-rows: 1* - Style URL
- Description
* - `py://nitpick/resources/markdown/markdownlint `_
- `Markdown lint `_presets
~~~~~~~.. list-table::
:header-rows: 1* - Style URL
- Description
* - `py://nitpick/resources/presets/nitpick `_
- `Default style file for Nitpick `_proto
~~~~~.. list-table::
:header-rows: 1* - Style URL
- Description
* - `py://nitpick/resources/proto/protolint `_
- `protolint (Protobuf linter) `_python
~~~~~~.. list-table::
:header-rows: 1* - Style URL
- Description
* - `py://nitpick/resources/python/310 `_
- Python 3.10
* - `py://nitpick/resources/python/311 `_
- Python 3.11
* - `py://nitpick/resources/python/312 `_
- Python 3.12
* - `py://nitpick/resources/python/38 `_
- Python 3.8
* - `py://nitpick/resources/python/39 `_
- Python 3.9
* - `py://nitpick/resources/python/absent `_
- Files that should not exist
* - `py://nitpick/resources/python/autoflake `_
- `autoflake `_
* - `py://nitpick/resources/python/bandit `_
- `Bandit `_
* - `py://nitpick/resources/python/black `_
- `Black `_
* - `py://nitpick/resources/python/flake8 `_
- `Flake8 `_
* - `py://nitpick/resources/python/github-workflow `_
- `GitHub Workflow for Python `_
* - `py://nitpick/resources/python/ipython `_
- `IPython `_
* - `py://nitpick/resources/python/isort `_
- `isort `_
* - `py://nitpick/resources/python/mypy `_
- `Mypy `_
* - `py://nitpick/resources/python/poetry-editable `_
- `Poetry (editable projects; PEP 600 support) `_
* - `py://nitpick/resources/python/poetry-venv `_
- `Poetry (virtualenv in project) `_
* - `py://nitpick/resources/python/poetry `_
- `Poetry `_
* - `py://nitpick/resources/python/pre-commit-hooks `_
- `pre-commit hooks for Python projects `_
* - `py://nitpick/resources/python/pylint `_
- `Pylint `_
* - `py://nitpick/resources/python/radon `_
- `Radon `_
* - `py://nitpick/resources/python/readthedocs `_
- `Read the Docs `_
* - `py://nitpick/resources/python/sonar-python `_
- `SonarQube Python plugin `_
* - `py://nitpick/resources/python/tox `_
- `tox `_shell
~~~~~.. list-table::
:header-rows: 1* - Style URL
- Description
* - `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) `_toml
~~~~.. list-table::
:header-rows: 1* - Style URL
- Description
* - `py://nitpick/resources/toml/toml-sort `_
- `TOML sort `_
.. auto-generated-end-style-libraryQuickstart
----------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/nitpickOn macOS/Linux, install with
`Homebrew `_::# Latest PyPI release
brew install andreoliwa/formulae/nitpick# Development branch from GitHub
brew install andreoliwa/formulae/nitpick --HEADOn 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
~~~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::repos:
- repo: https://github.com/andreoliwa/nitpick
rev: v0.35.0
hooks:
- id: nitpickThere are 3 available hook IDs:
- ``nitpick`` and ``nitpick-fix`` both run the ``nitpick fix`` command;
- ``nitpick-check`` runs ``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]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:
.. code-block:: yaml
PLUGINS:
- https://raw.githubusercontent.com/andreoliwa/nitpick/v0.35.0/mega-linter-plugin-nitpick/nitpick.megalinter-descriptor.yml
ENABLE_LINTERS:
- NITPICKMore information
----------------Nitpick is being used by projects such as:
- `wemake-services/wemake-python-styleguide `_
- `dry-python/returns `_
- `sobolevn/django-split-settings `_
- `catalyst-team/catalyst `_
- `alan-turing-institute/AutSPACEs `_
- `pytest-dev/pytest-mimesis `_For more details on styles and which configuration files are currently
supported, `see the full documentation `_... |PyPI| image:: https://img.shields.io/pypi/v/nitpick.svg
:target: https://pypi.org/project/nitpick
.. |GitHub Actions Python Workflow| image:: https://github.com/andreoliwa/nitpick/workflows/Python/badge.svg
.. |Documentation Status| image:: https://readthedocs.org/projects/nitpick/badge/?version=latest
:target: https://nitpick.rtfd.io/en/latest/?badge=latest
.. |Coveralls| image:: https://coveralls.io/repos/github/andreoliwa/nitpick/badge.svg
:target: https://coveralls.io/github/andreoliwa/nitpick
.. |Maintainability| image:: https://api.codeclimate.com/v1/badges/61e0cdc48e24e76a0460/maintainability
:target: https://codeclimate.com/github/andreoliwa/nitpick
.. |Test Coverage| image:: https://api.codeclimate.com/v1/badges/61e0cdc48e24e76a0460/test_coverage
:target: https://codeclimate.com/github/andreoliwa/nitpick
.. |Supported Python versions| image:: https://img.shields.io/pypi/pyversions/nitpick.svg
:target: https://pypi.org/project/nitpick/
.. |Project License| image:: https://img.shields.io/pypi/l/nitpick.svg
:target: https://pypi.org/project/nitpick/
.. |Code style: black| image:: https://img.shields.io/badge/code%20style-black-000000.svg
:target: https://github.com/psf/black
.. |Renovate| image:: https://img.shields.io/badge/renovate-enabled-brightgreen.svg
:target: https://renovatebot.com/
.. |semantic-release| image:: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg
:target: https://github.com/semantic-release/semantic-release
.. |pre-commit| image:: https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white
:target: https://github.com/pre-commit/pre-commit
:alt: pre-commit
.. |pre-commit.ci status| image:: https://results.pre-commit.ci/badge/github/andreoliwa/nitpick/develop.svg
:target: https://results.pre-commit.ci/latest/github/andreoliwa/nitpick/develop
.. |FOSSA Status| image:: https://app.fossa.com/api/projects/git%2Bgithub.com%2Fandreoliwa%2Fnitpick.svg?type=shield
:target: https://app.fossa.com/projects/git%2Bgithub.com%2Fandreoliwa%2Fnitpick?ref=badge_shieldContributing
------------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.