From 92c13ae57578f965beeefeadc7890df1b45c4c9a Mon Sep 17 00:00:00 2001 From: Augusto Wagner Andreoli Date: Wed, 19 Jun 2019 02:51:07 +0200 Subject: [PATCH] feat(pre-commit): add nitpick hooks to use on .pre-commit-config.yaml --- .pre-commit-config.yaml | 23 ++-- .pre-commit-hooks.yaml | 14 +++ Makefile | 1 - README.md | 28 ++++- poetry.lock | 206 +++++++++++++++++++++++++++++++-- pyproject.toml | 14 +++ setup.cfg | 4 +- styles/black.toml | 4 +- styles/flake8.toml | 10 +- styles/isort.toml | 2 +- styles/pre-commit/general.toml | 2 +- tests/test_pre_commit.py | 4 +- tests/test_style.py | 6 +- 13 files changed, 270 insertions(+), 48 deletions(-) create mode 100644 .pre-commit-hooks.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d666479b..0ce0b1ba 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,16 +10,16 @@ repos: - id: end-of-file-fixer - id: trailing-whitespace - repo: https://github.com/asottile/pyupgrade - rev: v1.18.0 + rev: v1.19.0 hooks: - id: pyupgrade - - repo: https://github.com/ambv/black + - repo: https://github.com/python/black rev: 19.3b0 hooks: - id: black args: [--safe, --quiet] - repo: https://github.com/asottile/blacken-docs - rev: v1.0.0 + rev: v1.0.0-1 hooks: - id: blacken-docs additional_dependencies: [black==19.3b0] @@ -39,13 +39,6 @@ repos: - id: python-no-eval - id: python-no-log-warn - id: rst-backticks - - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v2.2.3 - hooks: - - id: flake8 - additional_dependencies: [flake8-blind-except, flake8-bugbear, flake8-comprehensions, - flake8-debugger, flake8-docstrings, flake8-isort, flake8-mypy, flake8-polyfill, - flake8-pytest, flake8-quotes, yesqa] - repo: https://github.com/pre-commit/mirrors-mypy rev: v0.701 hooks: @@ -54,3 +47,13 @@ repos: rev: 0.6.0 hooks: - id: bashate + - repo: local + hooks: + # Run flake8 locally with nitpick and all the plugins configured in pyproject.toml + - id: nitpick-local + name: Nitpick (Local) + description: Check only nitpick errors (NIP) and ignore other flake8 plugins + entry: flake8 + language: python + types: [python] + always_run: true diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml new file mode 100644 index 00000000..6782b4a4 --- /dev/null +++ b/.pre-commit-hooks.yaml @@ -0,0 +1,14 @@ +- id: nitpick-all + name: Nitpick (All) + description: Run nitpick together with several other flake8 plugins (check pyproject.toml) + entry: flake8 + language: python + types: [python] + always_run: true +- id: nitpick-only + name: Nitpick (Only) + description: Check only nitpick errors (NIP) and ignore other flake8 plugins + entry: flake8 --select=NIP + language: python + types: [python] + always_run: true diff --git a/Makefile b/Makefile index c63ec379..cb6a8e5d 100644 --- a/Makefile +++ b/Makefile @@ -25,5 +25,4 @@ help: dev: clear pre-commit run --all-files - flake8 pytest diff --git a/README.md b/README.md index 592b9465..5e035798 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ [![Test Coverage](https://api.codeclimate.com/v1/badges/61e0cdc48e24e76a0460/test_coverage)](https://codeclimate.com/github/andreoliwa/nitpick/test_coverage) [![Supported Python versions](https://img.shields.io/pypi/pyversions/nitpick.svg)](https://pypi.org/project/nitpick/) [![Project License](https://img.shields.io/pypi/l/nitpick.svg)](https://pypi.org/project/nitpick/) -[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black) +[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/python/black) [![Dependabot Status](https://api.dependabot.com/badges/status?host=github&repo=andreoliwa/nitpick)](https://dependabot.com) [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) @@ -30,12 +30,28 @@ A "nitpick code style" is a [TOML](https://github.com/toml-lang/toml) file with ## Installation and usage -Simply install the package (in a virtualenv or globally, wherever) and run `flake8`: +To try the package, simply install it (in a virtualenv or globally, wherever) and run `flake8`: $ pip install -U nitpick $ flake8 -You will see warnings if your project configuration is different than [the default style file](https://raw.githubusercontent.com/andreoliwa/nitpick//0.15.0/nitpick-style.toml/nitpick-style.toml). +You will see warnings if your project configuration is different than [the default style file](https://raw.githubusercontent.com/andreoliwa/nitpick/0.15.0/nitpick-style.toml/nitpick-style.toml). + +### As a pre-commit hook + +If you use [pre-commit](https://pre-commit.com/) on your project, add this to the `.pre-commit-config.yaml` in your repository: + + repos: + - repo: https://github.com/andreoliwa/nitpick + rev: v0.15.0 + hooks: + # Run nitpick and several other flake8 plugins + - id: nitpick-all + # Check only nitpick errors, ignore other flake8 plugins + - id: nitpick-only + +Use one hook or the other (`nitpick-all` **or** `nitpick-only`), not both. +To check all the other flake8 plugins that are installed with `nitpick`, see the [pyproject.toml](pyproject.toml). ## Style file @@ -44,7 +60,7 @@ You will see warnings if your project configuration is different than [the defau Change your project config on `pyproject.toml`, and configure your own style like this: [tool.nitpick] - style = "https://raw.githubusercontent.com/andreoliwa/nitpick//0.15.0/nitpick-style.toml/nitpick-style.toml" + style = "https://raw.githubusercontent.com/andreoliwa/nitpick/0.15.0/nitpick-style.toml/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](https://gist.github.com). @@ -62,7 +78,7 @@ If a key is defined in more than one file, the value from the last file will pre 2. Any `nitpick-style.toml` file found in the current directory (the one in which `flake8` runs from) or above. -3. If no style is found, then [the default style file from GitHub](https://raw.githubusercontent.com/andreoliwa/nitpick//0.15.0/nitpick-style.toml/nitpick-style.toml) is used. +3. If no style is found, then [the default style file from GitHub](https://raw.githubusercontent.com/andreoliwa/nitpick/0.15.0/nitpick-style.toml/nitpick-style.toml) is used. ### Style file syntax @@ -70,7 +86,7 @@ A style file contains basically the configuration options you want to enforce in They are just the config to the tool, prefixed with the name of the config file. -E.g.: To [configure the black formatter](https://github.com/ambv/black#configuration-format) with a line length of 120, you use this in your `pyproject.toml`: +E.g.: To [configure the black formatter](https://github.com/python/black#configuration-format) with a line length of 120, you use this in your `pyproject.toml`: [tool.black] line-length = 120 diff --git a/poetry.lock b/poetry.lock index 562eb28a..235c9c01 100644 --- a/poetry.lock +++ b/poetry.lock @@ -135,6 +135,124 @@ mccabe = ">=0.6.0,<0.7.0" pycodestyle = ">=2.5.0,<2.6.0" pyflakes = ">=2.1.0,<2.2.0" +[[package]] +category = "main" +description = "A flake8 extension that checks for blind except: statements" +name = "flake8-blind-except" +optional = false +python-versions = "*" +version = "0.1.1" + +[package.dependencies] +setuptools = "*" + +[[package]] +category = "main" +description = "A plugin for flake8 finding likely bugs and design problems in your program. Contains warnings that don't belong in pyflakes and pycodestyle." +name = "flake8-bugbear" +optional = false +python-versions = ">=3.5" +version = "19.3.0" + +[package.dependencies] +attrs = "*" +flake8 = ">=3.0.0" + +[[package]] +category = "main" +description = "A flake8 plugin to help you write better list/set/dict comprehensions." +name = "flake8-comprehensions" +optional = false +python-versions = ">=3.4" +version = "2.1.0" + +[package.dependencies] +flake8 = "!=3.2.0" + +[[package]] +category = "main" +description = "ipdb/pdb statement checker plugin for flake8" +name = "flake8-debugger" +optional = false +python-versions = "*" +version = "3.1.0" + +[package.dependencies] +flake8 = ">=1.5" +pycodestyle = "*" + +[[package]] +category = "main" +description = "Extension for flake8 which uses pydocstyle to check docstrings" +name = "flake8-docstrings" +optional = false +python-versions = "*" +version = "1.3.0" + +[package.dependencies] +flake8 = "*" +flake8-polyfill = "*" +pydocstyle = ">=2.1" + +[[package]] +category = "main" +description = "flake8 plugin that integrates isort ." +name = "flake8-isort" +optional = false +python-versions = "*" +version = "2.7.0" + +[package.dependencies] +flake8 = ">=3.2.1" +isort = ">=4.3.0" +testfixtures = "*" + +[[package]] +category = "main" +description = "A plugin for flake8 integrating mypy." +name = "flake8-mypy" +optional = false +python-versions = "*" +version = "17.8.0" + +[package.dependencies] +attrs = "*" +flake8 = ">=3.0.0" +mypy = "*" + +[[package]] +category = "main" +description = "Polyfill package for Flake8 plugins" +name = "flake8-polyfill" +optional = false +python-versions = "*" +version = "1.0.2" + +[package.dependencies] +flake8 = "*" + +[[package]] +category = "main" +description = "pytest assert checker plugin for flake8" +name = "flake8-pytest" +optional = false +python-versions = "*" +version = "1.3" + +[package.dependencies] +flake8 = "*" + +[[package]] +category = "main" +description = "Flake8 lint for quotes." +name = "flake8-quotes" +optional = false +python-versions = "*" +version = "2.0.1" + +[package.dependencies] +flake8 = "*" + [[package]] category = "main" description = "Internationalized Domain Names in Applications (IDNA)" @@ -211,7 +329,7 @@ python-versions = "*" version = "0.2.0" [[package]] -category = "dev" +category = "main" description = "A Python utility / library to sort Python imports." name = "isort" optional = false @@ -281,6 +399,26 @@ optional = false python-versions = ">=3.4" version = "7.0.0" +[[package]] +category = "main" +description = "Optional static typing for Python (mypyc-compiled version)" +name = "mypy" +optional = false +python-versions = "*" +version = "0.701" + +[package.dependencies] +mypy-extensions = ">=0.4.0,<0.5.0" +typed-ast = ">=1.3.1,<1.4.0" + +[[package]] +category = "main" +description = "Experimental type system extensions for programs checked with the mypy typechecker." +name = "mypy-extensions" +optional = false +python-versions = "*" +version = "0.4.1" + [[package]] category = "dev" description = "Core utilities for Python packages" @@ -381,6 +519,18 @@ optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" version = "2.5.0" +[[package]] +category = "main" +description = "Python docstring style checker" +name = "pydocstyle" +optional = false +python-versions = "*" +version = "3.0.0" + +[package.dependencies] +six = "*" +snowballstemmer = "*" + [[package]] category = "main" description = "passive checker of Python programs" @@ -522,7 +672,7 @@ python-versions = "*" version = "0.15.97" [[package]] -category = "dev" +category = "main" description = "Python 2 and 3 compatibility utilities" name = "six" optional = false @@ -530,7 +680,7 @@ python-versions = ">=2.6, !=3.0.*, !=3.1.*" version = "1.12.0" [[package]] -category = "dev" +category = "main" description = "This package provides 16 stemmer algorithms (15 + Poerter English stemmer) generated from Snowball algorithms." name = "snowballstemmer" optional = false @@ -632,7 +782,7 @@ python-versions = "*" version = "1.1.3" [[package]] -category = "dev" +category = "main" description = "A collection of helpers and mock objects for unit tests and doc tests." name = "testfixtures" optional = false @@ -647,6 +797,14 @@ optional = false python-versions = "*" version = "1.2" +[[package]] +category = "main" +description = "A wrapper around the stdlib `tokenize` which roundtrips." +name = "tokenize-rt" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" +version = "3.0.1" + [[package]] category = "main" description = "Python Library for Tom's Obvious, Minimal Language" @@ -669,13 +827,12 @@ ipython-genutils = "*" six = "*" [[package]] -category = "dev" +category = "main" description = "a fork of Python 2 and 3 ast modules with type comment support" -marker = "implementation_name == \"cpython\"" name = "typed-ast" optional = false python-versions = "*" -version = "1.4.0" +version = "1.3.5" [[package]] category = "main" @@ -708,7 +865,19 @@ description = "Module for decorators, wrappers and monkey patching." name = "wrapt" optional = false python-versions = "*" -version = "1.11.1" +version = "1.11.2" + +[[package]] +category = "main" +description = "Automatically remove unnecessary `# noqa` comments." +name = "yesqa" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" +version = "0.0.11" + +[package.dependencies] +flake8 = ">=3.7" +tokenize-rt = ">=2.1" [[package]] category = "dev" @@ -719,7 +888,7 @@ python-versions = ">=2.7" version = "0.5.1" [metadata] -content-hash = "2178a39b04a309fffde02d566178c8d2a37ba4c356d722ff29e0842ba7737069" +content-hash = "9adb904715d0e867ffeb30653ace0d226b2830c249c9eaabb4728437e75a814f" python-versions = "^3.5 || ^3.6 || ^3.7" [metadata.hashes] @@ -738,6 +907,16 @@ dictdiffer = ["97cf4ef98ebc1acf737074aed41e379cf48ab5ff528c92109dfb8e2e619e6809" docutils = ["02aec4bd92ab067f6ff27a38a38a41173bf01bed8f89157768c1573f53e474a6", "51e64ef2ebfb29cae1faa133b3710143496eca21c530f3f71424d77687764274", "7a4bd47eaf6596e1295ecb11361139febe29b084a87bf005bf899f9a42edc3c6"] entrypoints = ["589f874b313739ad35be6e0cd7efde2a4e9b6fea91edcc34e58ecbb8dbe56d19", "c70dd71abe5a8c85e55e12c19bd91ccfeec11a6e99044204511f9ed547d48451"] flake8 = ["859996073f341f2670741b51ec1e67a01da142831aa1fdc6242dbf88dffbe661", "a796a115208f5c03b18f332f7c11729812c8c3ded6c46319c59b53efd3819da8"] +flake8-blind-except = ["0d7d1adb4cabf2268d6eebb815a7a5014bcb7e8419f7a74339c46d0b8847b858", "aca3356633825544cec51997260fe31a8f24a1a2795ce8e81696b9916745e599"] +flake8-bugbear = ["5070774b668be92c4312e5ca82748ddf4ecaa7a24ff062662681bb745c7896eb", "fef9c9826d14ec23187ae1edeb3c6513c4e46bf0e70d86bac38f7d9aabae113d"] +flake8-comprehensions = ["35f826956e87f230415cde9c3b8b454e785736cf5ff0be551c441b41b937f699", "f0b61d983d608790abf3664830d68efd3412265c2d10f6a4ba1a353274dbeb64"] +flake8-debugger = ["be4fb88de3ee8f6dd5053a2d347e2c0a2b54bab6733a2280bb20ebd3c4ca1d97"] +flake8-docstrings = ["4e0ce1476b64e6291520e5570cf12b05016dd4e8ae454b8a8a9a48bc5f84e1cd", "8436396b5ecad51a122a2c99ba26e5b4e623bf6e913b0fea0cb6c2c4050f91eb"] +flake8-isort = ["1e67b6b90a9b980ac3ff73782087752d406ce0a729ed928b92797f9fa188917e", "81a8495eefed3f2f63f26cd2d766c7b1191e923a15b9106e6233724056572c68"] +flake8-mypy = ["47120db63aff631ee1f84bac6fe8e64731dc66da3efc1c51f85e15ade4a3ba18", "cff009f4250e8391bf48990093cff85802778c345c8449d6498b62efefeebcbc"] +flake8-polyfill = ["12be6a34ee3ab795b19ca73505e7b55826d5f6ad7230d31b18e106400169b9e9", "e44b087597f6da52ec6393a709e7108b2905317d0c0b744cdca6208e670d8eda"] +flake8-pytest = ["61686128a79e1513db575b2bcac351081d5a293811ddce2d5dfc25e8c762d33e", "b4d6703f7d7b646af1e2660809e795886dd349df11843613dbe6515efa82c0f3"] +flake8-quotes = ["10c9af6b472d4302a8e721c5260856c3f985c5c082b04841aefd2f808ac02038"] idna = ["c357b3f628cf53ae2c4c05627ecc484553142ca23264e593d327bcde5e9c3407", "ea8b7f6188e6fa117537c3df7da9fc686d485087abf6ac197f9c46432f7e4a3c"] imagesize = ["3f349de3eb99145973fefb7dbe38554414e5c30abd0c8e4b970a7c9d09f3a1d8", "f3832918bc3c66617f92e35f5d70729187676313caa60c187eb0f28b8fe5e3b5"] importlib-metadata = ["6dfd58dfe281e8d240937776065dd3624ad5469c835248219bd16cf2e12dbeb7", "cb6ee23b46173539939964df59d3d72c3e0c1b5d54b84f1d8a7e912fe43612db"] @@ -752,6 +931,8 @@ lazy-object-proxy = ["159a745e61422217881c4de71f9eafd9d703b93af95618635849fe469a markupsafe = ["00bc623926325b26bb9605ae9eae8a215691f33cae5df11ca5424f06f2d1f473", "09027a7803a62ca78792ad89403b1b7a73a01c8cb65909cd876f7fcebd79b161", "09c4b7f37d6c648cb13f9230d847adf22f8171b1ccc4d5682398e77f40309235", "1027c282dad077d0bae18be6794e6b6b8c91d58ed8a8d89a89d59693b9131db5", "24982cc2533820871eba85ba648cd53d8623687ff11cbb805be4ff7b4c971aff", "29872e92839765e546828bb7754a68c418d927cd064fd4708fab9fe9c8bb116b", "43a55c2930bbc139570ac2452adf3d70cdbb3cfe5912c71cdce1c2c6bbd9c5d1", "46c99d2de99945ec5cb54f23c8cd5689f6d7177305ebff350a58ce5f8de1669e", "500d4957e52ddc3351cabf489e79c91c17f6e0899158447047588650b5e69183", "535f6fc4d397c1563d08b88e485c3496cf5784e927af890fb3c3aac7f933ec66", "62fe6c95e3ec8a7fad637b7f3d372c15ec1caa01ab47926cfdf7a75b40e0eac1", "6dd73240d2af64df90aa7c4e7481e23825ea70af4b4922f8ede5b9e35f78a3b1", "717ba8fe3ae9cc0006d7c451f0bb265ee07739daf76355d06366154ee68d221e", "79855e1c5b8da654cf486b830bd42c06e8780cea587384cf6545b7d9ac013a0b", "7c1699dfe0cf8ff607dbdcc1e9b9af1755371f92a68f706051cc8c37d447c905", "88e5fcfb52ee7b911e8bb6d6aa2fd21fbecc674eadd44118a9cc3863f938e735", "8defac2f2ccd6805ebf65f5eeb132adcf2ab57aa11fdf4c0dd5169a004710e7d", "98c7086708b163d425c67c7a91bad6e466bb99d797aa64f965e9d25c12111a5e", "9add70b36c5666a2ed02b43b335fe19002ee5235efd4b8a89bfcf9005bebac0d", "9bf40443012702a1d2070043cb6291650a0841ece432556f784f004937f0f32c", "ade5e387d2ad0d7ebf59146cc00c8044acbd863725f887353a10df825fc8ae21", "b00c1de48212e4cc9603895652c5c410df699856a2853135b3967591e4beebc2", "b1282f8c00509d99fef04d8ba936b156d419be841854fe901d8ae224c59f0be5", "b2051432115498d3562c084a49bba65d97cf251f5a331c64a12ee7e04dacc51b", "ba59edeaa2fc6114428f1637ffff42da1e311e29382d81b339c1817d37ec93c6", "c8716a48d94b06bb3b2524c2b77e055fb313aeb4ea620c8dd03a105574ba704f", "cd5df75523866410809ca100dc9681e301e3c27567cf498077e8551b6d20e42f", "e249096428b3ae81b08327a63a485ad0878de3fb939049038579ac0ef61e17e7"] mccabe = ["ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42", "dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f"] more-itertools = ["2112d2ca570bb7c3e53ea1a35cd5df42bb0fd10c45f0fb97178679c3c03d64c7", "c3e4748ba1aad8dba30a4886b0b1a2004f9a863837b8654e7059eebf727afa5a"] +mypy = ["2afe51527b1f6cdc4a5f34fc90473109b22bf7f21086ba3e9451857cf11489e6", "56a16df3e0abb145d8accd5dbb70eba6c4bd26e2f89042b491faa78c9635d1e2", "5764f10d27b2e93c84f70af5778941b8f4aa1379b2430f85c827e0f5464e8714", "5bbc86374f04a3aa817622f98e40375ccb28c4836f36b66706cf3c6ccce86eda", "6a9343089f6377e71e20ca734cd8e7ac25d36478a9df580efabfe9059819bf82", "6c9851bc4a23dc1d854d3f5dfd5f20a016f8da86bcdbb42687879bb5f86434b0", "b8e85956af3fcf043d6f87c91cbe8705073fc67029ba6e22d3468bfee42c4823", "b9a0af8fae490306bc112229000aa0c2ccc837b49d29a5c42e088c132a2334dd", "bbf643528e2a55df2c1587008d6e3bda5c0445f1240dfa85129af22ae16d7a9a", "c46ab3438bd21511db0f2c612d89d8344154c0c9494afc7fbc932de514cf8d15", "f7a83d6bd805855ef83ec605eb01ab4fa42bcef254b13631e451cbb44914a9b0"] +mypy-extensions = ["37e0e956f41369209a3d5f34580150bcacfabaa57b33a15c0b25f4b5725e0812", "b16cabe759f55e3409a7d231ebd2841378fb0c27a5d1994719e340e4f429ac3e"] packaging = ["0c98a5d0be38ed775798ece1b9727178c4469d9c3b4ada66e8e6b7849f8732af", "9e1cbf8c12b1f1ce0bb5344b8d7ecf66a6f8a6e91bcb0c84593ed6d3ab5c4ab3"] parso = ["17cc2d7a945eb42c3569d4564cdf49bde221bc2b552af3eca9c1aad517dcdd33", "2e9574cb12e7112a87253e14e2c380ce312060269d04bd018478a3c92ea9a376"] pathlib2 = ["25199318e8cc3c25dcb45cbe084cc061051336d5a9ea2a12448d3d8cb748f742", "5887121d7f7df3603bca2f710e7219f3eca0eb69e0b7cc6e0a022e155ac931a7"] @@ -762,6 +943,7 @@ prompt-toolkit = ["11adf3389a996a6d45cc277580d0d53e8a5afd281d0c9ec71b28e6f121463 ptyprocess = ["923f299cc5ad920c68f2bc0bc98b75b9f838b93b599941a6b63ddbc2476394c0", "d7cc528d76e76342423ca640335bd3633420dc1366f258cb31d05e865ef5ca1f"] py = ["64f65755aee5b381cea27766a3a147c3f15b9b6b9ac88676de66ba2ae36793fa", "dc639b046a6e2cff5bbe40194ad65936d6ba360b52b3c3fe1d08a82dd50b5e53"] pycodestyle = ["95a2219d12372f05704562a14ec30bc76b05a5b297b21a5dfe3f6fac3491ae56", "e40a936c9a450ad81df37f549d676d127b1b66000a6c500caa2b085bc0ca976c"] +pydocstyle = ["2258f9b0df68b97bf3a6c29003edc5238ff8879f1efb6f1999988d934e432bd8", "5741c85e408f9e0ddf873611085e819b809fca90b619f5fd7f34bd4959da3dd4", "ed79d4ec5e92655eccc21eb0c6cf512e69512b4a97d215ace46d17e4990f2039"] pyflakes = ["17dbeb2e3f4d772725c777fabc446d5634d1038f234e77343108ce445ea69ce0", "d976835886f8c5b31d47970ed689944a0262b5f3afa00a5a7b4dc81e5449f8a2"] pygments = ["71e430bc85c88a430f000ac1d9b331d2407f681d6f6aec95e8bcfbc3df5b0127", "881c4c157e45f30af185c1ffe8d549d48ac9127433f2c380c24b84572ad66297"] pylint = ["5d77031694a5fb97ea95e828c8d10fc770a1df6eb3906067aaed42201a8a6a09", "723e3db49555abaf9bf79dc474c6b9e2935ad82230b10c1138a71ea41ac0fff1"] @@ -787,11 +969,13 @@ sphinxcontrib-qthelp = ["513049b93031beb1f57d4daea74068a4feb77aa5630f856fcff2e50 sphinxcontrib-serializinghtml = ["c0efb33f8052c04fd7a26c0a07f1678e8512e0faec19f4aa8f2473a8b81d5227", "db6615af393650bf1151a6cd39120c29abaf93cc60db8c48eb2dddbfdc3a9768"] testfixtures = ["1fec9b69328777c7ca4b0f645325ce71de5368551e897b957d514d0f9bb10d3e", "772c9e3a2743782c9e432de4334da71d2896a94a35748d60dbcdd30271010beb"] text-unidecode = ["5a1375bb2ba7968740508ae38d92e1f889a0832913cb1c447d5e2046061a396d", "801e38bd550b943563660a91de8d4b6fa5df60a542be9093f7abf819f86050cc"] +tokenize-rt = ["c65559bd0574447e10348f0f18710e870f862e168d673157f9b5eb43fb1b7eff", "ff2d4e39e924aa6998cf415efbfc4e8476b85215b4d094add79eacaeffd8bf12"] toml = ["229f81c57791a41d65e399fc06bf0848bab550a9dfd5ed66df18ce5f05e73d5c", "235682dd292d5899d361a811df37e04a8828a5b1da3115886b73cf81ebc9100e", "f1db651f9657708513243e61e6cc67d101a39bad662eaa9b5546f789338e07a3"] traitlets = ["9c4bd2d267b7153df9152698efb1050a5d84982d3384a37b2c1f7723ba3e7835", "c6cb5e6f57c5a9bdaa40fa71ce7b4af30298fbab9ece9815b5d995ab6217c7d9"] -typed-ast = ["18511a0b3e7922276346bcb47e2ef9f38fb90fd31cb9223eed42c85d1312344e", "262c247a82d005e43b5b7f69aff746370538e176131c32dda9cb0f324d27141e", "2b907eb046d049bcd9892e3076c7a6456c93a25bebfe554e931620c90e6a25b0", "354c16e5babd09f5cb0ee000d54cfa38401d8b8891eefa878ac772f827181a3c", "4e0b70c6fc4d010f8107726af5fd37921b666f5b31d9331f0bd24ad9a088e631", "630968c5cdee51a11c05a30453f8cd65e0cc1d2ad0d9192819df9978984529f4", "66480f95b8167c9c5c5c87f32cf437d585937970f3fc24386f313a4c97b44e34", "71211d26ffd12d63a83e079ff258ac9d56a1376a25bc80b1cdcdf601b855b90b", "95bd11af7eafc16e829af2d3df510cecfd4387f6453355188342c3e79a2ec87a", "bc6c7d3fa1325a0c6613512a093bc2a2a15aeec350451cbdf9e1d4bffe3e3233", "cc34a6f5b426748a507dd5d1de4c1978f2eb5626d51326e43280941206c209e1", "d755f03c1e4a51e9b24d899561fec4ccaf51f210d52abdf8c07ee2849b212a36", "d7c45933b1bdfaf9f36c579671fec15d25b06c8398f113dab64c18ed1adda01d", "d896919306dd0aa22d0132f62a1b78d11aaf4c9fc5b3410d3c666b818191630a", "ffde2fbfad571af120fcbfbbc61c72469e72f550d676c3342492a9dfdefb8f12"] +typed-ast = ["132eae51d6ef3ff4a8c47c393a4ef5ebf0d1aecc96880eb5d6c8ceab7017cc9b", "18141c1484ab8784006c839be8b985cfc82a2e9725837b0ecfa0203f71c4e39d", "2baf617f5bbbfe73fd8846463f5aeafc912b5ee247f410700245d68525ec584a", "3d90063f2cbbe39177e9b4d888e45777012652d6110156845b828908c51ae462", "4304b2218b842d610aa1a1d87e1dc9559597969acc62ce717ee4dfeaa44d7eee", "4983ede548ffc3541bae49a82675996497348e55bafd1554dc4e4a5d6eda541a", "5315f4509c1476718a4825f45a203b82d7fdf2a6f5f0c8f166435975b1c9f7d4", "6cdfb1b49d5345f7c2b90d638822d16ba62dc82f7616e9b4caa10b72f3f16649", "7b325f12635598c604690efd7a0197d0b94b7d7778498e76e0710cd582fd1c7a", "8d3b0e3b8626615826f9a626548057c5275a9733512b137984a68ba1598d3d2f", "8f8631160c79f53081bd23446525db0bc4c5616f78d04021e6e434b286493fd7", "912de10965f3dc89da23936f1cc4ed60764f712e5fa603a09dd904f88c996760", "b010c07b975fe853c65d7bbe9d4ac62f1c69086750a574f6292597763781ba18", "c908c10505904c48081a5415a1e295d8403e353e0c14c42b6d67f8f97fae6616", "c94dd3807c0c0610f7c76f078119f4ea48235a953512752b9175f9f98f5ae2bd", "ce65dee7594a84c466e79d7fb7d3303e7295d16a83c22c7c4037071b059e2c21", "eaa9cfcb221a8a4c2889be6f93da141ac777eb8819f077e1d09fb12d00a09a93", "f3376bc31bad66d46d44b4e6522c5c21976bf9bca4ef5987bb2bf727f4506cbb", "f9202fa138544e13a4ec1a6792c35834250a85958fde1251b6a22e07d1260ae7"] urllib3 = ["b246607a25ac80bedac05c6f282e3cdaf3afb65420fd024ac94435cabe6e18d1", "dbe59173209418ae49d485b87d1681aefa36252ee85884c31346debd19463232"] wcwidth = ["3df37372226d6e63e1b1e1eda15c594bca98a22d33a23832a90998faa96bc65e", "f4ebe71925af7b40a864553f761ed559b43544f8f71746c2d756c7fe788ade7c"] win-unicode-console = ["d4142d4d56d46f449d6f00536a73625a871cba040f0bc1a2e305a04578f07d1e"] -wrapt = ["4aea003270831cceb8a90ff27c4031da6ead7ec1886023b80ce0dfe0adf61533"] +wrapt = ["565a021fd19419476b9362b05eeaa094178de64f8361e44468f9e9d7843901e1"] +yesqa = ["531fa12d344509698d42e7c004ede340e8da239966ef755662fdff7a8e80988b", "7861ea3f835716c5c775725a6248adc55f7c5c7cb681f555042bc4dd8a99a1b0"] zipp = ["8c1019c6aad13642199fbe458275ad6a84907634cc9f0989877ccc4a2840139d", "ca943a7e809cc12257001ccfb99e3563da9af99d52f261725e96dfe0f9275bc3"] diff --git a/pyproject.toml b/pyproject.toml index 5b93b78f..5f72444d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,6 +39,20 @@ python-slugify = "*" jmespath = "*" sortedcontainers = "*" +# All flake8 plugins that are recommended by this opinionated project should be installed as dependencies, +# so they can run in the look pre-commit hook and also on projects that use the nitpick* hooks. +flake8-blind-except = "*" +flake8-bugbear = "*" +flake8-comprehensions = "*" +flake8-debugger = "*" +flake8-docstrings = "*" +flake8-isort = "*" +flake8-mypy = "*" +flake8-polyfill = "*" +flake8-pytest = "*" +flake8-quotes = "*" +yesqa = "*" + [tool.poetry.dev-dependencies] ipython = "*" ipdb = "*" diff --git a/setup.cfg b/setup.cfg index 334c4cf6..e96deef5 100644 --- a/setup.cfg +++ b/setup.cfg @@ -24,8 +24,8 @@ search = /{current_version}/nitpick-style.toml replace = /{new_version}/nitpick-style.toml [bumpversion:file:README.md] -search = /{current_version}/nitpick-style.toml -replace = /{new_version}/nitpick-style.toml +search = {current_version} +replace = {new_version} [flake8] ignore = D107,D401,D202,D203,E203,E402,E501,W503 diff --git a/styles/black.toml b/styles/black.toml index 098fef5f..a03efba5 100644 --- a/styles/black.toml +++ b/styles/black.toml @@ -3,13 +3,13 @@ line-length = 120 [["pre-commit-config.yaml".repos]] yaml = """ - - repo: https://github.com/ambv/black + - repo: https://github.com/python/black rev: 19.3b0 hooks: - id: black args: [--safe, --quiet] - repo: https://github.com/asottile/blacken-docs - rev: v1.0.0 + rev: v1.0.0-1 hooks: - id: blacken-docs additional_dependencies: [black==19.3b0] diff --git a/styles/flake8.toml b/styles/flake8.toml index 7dcebe5a..6fd9d67f 100644 --- a/styles/flake8.toml +++ b/styles/flake8.toml @@ -1,18 +1,10 @@ ["setup.cfg".flake8] # http://www.pydocstyle.org/en/2.1.1/error_codes.html -# Ignoring W503: https://github.com/ambv/black#line-breaks--binary-operators +# Ignoring W503: https://github.com/python/black#line-breaks--binary-operators # Ignoring "D202 No blank lines allowed after function docstring": black inserts a blank line. ignore = "D107,D202,D203,D401,E203,E402,E501,W503" max-line-length = 120 inline-quotes = "double" exclude = ".tox,build" -[["pre-commit-config.yaml".repos]] -yaml = """ - - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v2.2.3 - hooks: - - id: flake8 - additional_dependencies: [flake8-blind-except, flake8-bugbear, flake8-comprehensions, flake8-debugger, flake8-docstrings, flake8-isort, flake8-mypy, flake8-polyfill, flake8-pytest, flake8-quotes, yesqa] -""" # TODO suggest nitpick for external repos diff --git a/styles/isort.toml b/styles/isort.toml index b1d3470f..76e19fad 100644 --- a/styles/isort.toml +++ b/styles/isort.toml @@ -4,7 +4,7 @@ skip = ".tox,build" known_first_party = "tests" # The configuration below is needed for compatibility with black. -# https://github.com/ambv/black#how-black-wraps-lines +# https://github.com/python/black#how-black-wraps-lines # https://github.com/timothycrosley/isort#multi-line-output-modes multi_line_output = 3 include_trailing_comma = true diff --git a/styles/pre-commit/general.toml b/styles/pre-commit/general.toml index c582073d..46b6fde2 100644 --- a/styles/pre-commit/general.toml +++ b/styles/pre-commit/general.toml @@ -7,7 +7,7 @@ yaml = """ - id: end-of-file-fixer - id: trailing-whitespace - repo: https://github.com/asottile/pyupgrade - rev: v1.18.0 + rev: v1.19.0 hooks: - id: pyupgrade """ diff --git a/tests/test_pre_commit.py b/tests/test_pre_commit.py index d780519f..40197d5a 100644 --- a/tests/test_pre_commit.py +++ b/tests/test_pre_commit.py @@ -33,13 +33,13 @@ def test_suggest_initial_contents(request): rev: v4.3.20 hooks: - id: isort - - repo: https://github.com/ambv/black + - repo: https://github.com/python/black rev: 19.3b0 hooks: - id: black args: [--safe, --quiet] - repo: https://github.com/asottile/blacken-docs - rev: v1.0.0 + rev: v1.0.0-1 hooks: - id: blacken-docs additional_dependencies: [black==19.3b0] diff --git a/tests/test_style.py b/tests/test_style.py index ce0af1ba..c5988707 100644 --- a/tests/test_style.py +++ b/tests/test_style.py @@ -426,7 +426,7 @@ def test_merge_styles_into_single_file(request): known_first_party = "tests" # The configuration below is needed for compatibility with black. - # https://github.com/ambv/black#how-black-wraps-lines + # https://github.com/python/black#how-black-wraps-lines # https://github.com/timothycrosley/isort#multi-line-output-modes multi_line_output = 6 include_trailing_comma = true @@ -436,13 +436,13 @@ def test_merge_styles_into_single_file(request): [["pre-commit-config.yaml".repos]] yaml = """ - - repo: https://github.com/ambv/black + - repo: https://github.com/python/black rev: 19.3b0 hooks: - id: black args: [--safe, --quiet] - repo: https://github.com/asottile/blacken-docs - rev: v1.0.0 + rev: v1.0.0-1 hooks: - id: blacken-docs additional_dependencies: [black==19.3b0]