Flake8 plugin to enforce the same lint configuration (flake8, isort, mypy, pylint) across multiple Python projects
Flake8 plugin to enforce the same lint configuration (flake8, isort, mypy, pylint) across multiple Python projects.
A "nitpick code style" is a TOML file with settings that should be present in config files from other tools. E.g.:
setup.cfg(used by flake8, black, isort, mypy);
.pylintrc(used by pylint config);
- more files to come.
Installation and usage
Simply install the package (in a virtualenv or globally, wherever) and run
$ pip install -U flake8-nitpick $ flake8
You will see warnings if your project configuration is different than the default style file.
Configure your own style file
Change your project config on
pyproject.toml, and configure your own style like this:
[tool.nitpick] style = "https://raw.githubusercontent.com/andreoliwa/flake8-nitpick/master/nitpick-style.toml"
You can set
style with any local file or URL. E.g.: you can use the raw URL of a GitHub Gist.
You can also use multiple styles and mix local files and URLs:
[tool.nitpick] style = ["/path/to/first.toml", "/another/path/to/second.toml", "https://example.com/on/the/web/third.toml"]
The order is important: each style will override any keys that might be set by the previous .toml file. If a key is defined in more than one file, the value from the last file will prevail.
Default search order for a style file
A file or URL configured in the
stylekey, as described above.
nitpick-style.tomlfile found in the current directory (the one in which
flake8runs from) or above.
If no style is found, then the default style file from GitHub is used.
Style file syntax
A style file contains basically the configuration options you want to enforce in all your projects.
They are just the config to the tool, prefixed with the name of the config file.
E.g.: To configure the black formatter with a line length of 120, you use this in your
[tool.black] line-length = 120
To enforce that all your projects use this same line length, add this to your
["pyproject.toml".tool.black] line-length = 120
It's the same exact section/key, just prefixed with the config file name (
The same works for
To configure mypy to ignore missing imports in your project:
[mypy] ignore_missing_imports = true
To enforce all your projects to ignore missing imports, add this to your
["setup.cfg".mypy] ignore_missing_imports = true
To enforce that certain files should not exist in the project, you can add them to the style file.
[[files.absent]] file = "myfile1.txt" [[files.absent]] file = "another_file.env" message = "This is an optional extra string to display after the warning"
Multiple files can be configured as above.
message is optional.
Comma separated values
setup.cfg, some keys are lists of multiple values separated by commas, like
On the style file, it's possible to indicate which key/value pairs should be treated as multiple values instead of an exact string. Multiple keys can be added.
["setup.cfg".nitpick] comma_separated_values = ["flake8.ignore", "isort.some_key", "another_section.another_key"]
Release history Release notifications
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size & hash SHA256 hash help||File type||Python version||Upload date|
|flake8_nitpick-0.10.3-py3-none-any.whl (42.3 kB) Copy SHA256 hash SHA256||Wheel||py3|
|flake8-nitpick-0.10.3.tar.gz (15.8 kB) Copy SHA256 hash SHA256||Source||None|