From: Ɓukasz Langa Date: Wed, 4 Apr 2018 20:19:30 +0000 (-0700) Subject: Add integration for pre-commit.com (#104) X-Git-Url: https://git.madduck.net/etc/vim.git/commitdiff_plain/f8e9544c930a1469bee8b3f131687e2cae52e59b?ds=inline Add integration for pre-commit.com (#104) Fixes #103 --- diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..b87604a --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,19 @@ +# Note: don't use this config for your own repositories. Instead, see +# "Version control integration" in README.md. +- repo: local + hooks: + - id: black + name: black + language: system + entry: python3 -m black + files: ^(black|setup|tests/test_black)\.py$ + - id: flake8 + name: flake8 + language: system + entry: flake8 + files: ^(black|setup|tests/test_black)\.py$ + - id: mypy + name: mypy + language: system + entry: mypy + files: ^(black|setup|tests/test_black)\.py$ diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml new file mode 100644 index 0000000..e7b45ef --- /dev/null +++ b/.pre-commit-hooks.yaml @@ -0,0 +1,6 @@ +- id: black + name: black + entry: black + language: python + language_version: python3.6 + types: [python] diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 455a7c7..7008ecb 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -30,6 +30,7 @@ myself and CentOS at work. Install all development dependencies using: ``` $ pipenv install --dev +$ pre-commit install ``` If you haven't used `pipenv` before but are comfortable with virtualenvs, just run `pip install pipenv` in the virtualenv you're already using and @@ -41,10 +42,6 @@ Before submitting pull requests, run tests with: $ python setup.py test ``` -Also run mypy and flake8 on `black.py` and `test_black.py`. Travis will -run all that for you but if you left any errors here, it will be quicker -and less embarrassing to fix them locally ;-) - ## Hygiene diff --git a/Pipfile b/Pipfile index bcd8c8a..4e0d4be 100644 --- a/Pipfile +++ b/Pipfile @@ -9,6 +9,7 @@ click = "*" setuptools = ">=38.6.0" [dev-packages] +pre-commit = "*" coverage = "*" flake8 = "*" flake8-bugbear = "*" diff --git a/Pipfile.lock b/Pipfile.lock index 68010ab..b6689f7 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "51d523fcd093fbf1fd034cd7ad0be9d34dc0fead60b2e23558b4a54f5c0c0ef6" + "sha256": "40e1fcca5bf4adcd0e688675714c4b2a771009b6e2005a0f375de1a46a64c906" }, "pipfile-spec": 6, "requires": {}, @@ -39,6 +39,13 @@ ], "version": "==0.7.10" }, + "aspy.yaml": { + "hashes": [ + "sha256:6215f44900ff65f27dbd00a36b06a7926276436ed377320cfd4febd69bbd4a94", + "sha256:be70cc0ccd1ee1d30f589f2403792eb2ffa7546470af0a17179541b13d8374df" + ], + "version": "==1.0.0" + }, "attrs": { "hashes": [ "sha256:1c7960ccfd6a005cd9f7ba884e6316b5e430a3f1a6c37c5f87d8b43f83b54ec9", @@ -54,6 +61,13 @@ ], "version": "==2.5.3" }, + "cached-property": { + "hashes": [ + "sha256:6e6935ec62567fbcbc346fad84fcea9bc77e3547b7267e62bc5b7ed8e5438ae8", + "sha256:a2fa0f89dd422f7e5dd992a4a3e0ce209d5d1e47a4db28fd0a7b5273ec8da3f0" + ], + "version": "==1.4.0" + }, "certifi": { "hashes": [ "sha256:14131608ad2fd56836d33a71ee60fa1c82bc9d2c8d98b7bdbc631fe1b3cd1296", @@ -61,6 +75,13 @@ ], "version": "==2018.1.18" }, + "cfgv": { + "hashes": [ + "sha256:2fbaf8d082456d8fff5a68163ff59c1025a52e906914fbc738be7d8ea5b7aa4b", + "sha256:733aa2f66b5106af32d271336a571610b9808e868de0ad5690d9d5155e5960c5" + ], + "version": "==1.0.0" + }, "chardet": { "hashes": [ "sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae", @@ -148,6 +169,13 @@ "index": "pypi", "version": "==17.8.0" }, + "identify": { + "hashes": [ + "sha256:53be6ea950a5f40e13be2dd87e67413eb6879527b831333196ab2a54de38f499", + "sha256:c0bfb29634e04cde8e54aee2d55aff9dad30d6ea1f3e9e3ce731934d78635aa1" + ], + "version": "==1.0.8" + }, "idna": { "hashes": [ "sha256:2c6a5de3089009e3da7c5dde64a141dbc8551d5b7f6cf4ed7c2568d0cc520a8f", @@ -190,6 +218,12 @@ "index": "pypi", "version": "==0.580" }, + "nodeenv": { + "hashes": [ + "sha256:dd0a34001090ff042cfdb4b0c8d6a6f7ec9baa49733f00b695bb8a8b4700ba6c" + ], + "version": "==1.3.0" + }, "packaging": { "hashes": [ "sha256:e9215d2d2535d3ae866c3d6efc77d5b24a0192cce0ff20e42896cc0664f889c0", @@ -204,6 +238,14 @@ ], "version": "==1.4.2" }, + "pre-commit": { + "hashes": [ + "sha256:01bb5f44606735ca30c8be641fa24f5760fcc599a0260ead0067bcde2f0305f9", + "sha256:823452163aa9fb024a9ff30947ba7f5a2778708db7554a4d36438b9bbead6bbb" + ], + "index": "pypi", + "version": "==1.8.2" + }, "pycodestyle": { "hashes": [ "sha256:682256a5b318149ca0d2a9185d365d8864a768a28db66a84a2ea946bcc426766", @@ -251,6 +293,25 @@ ], "version": "==2018.3" }, + "pyyaml": { + "hashes": [ + "sha256:0c507b7f74b3d2dd4d1322ec8a94794927305ab4cebbe89cc47fe5e81541e6e8", + "sha256:16b20e970597e051997d90dc2cddc713a2876c47e3d92d59ee198700c5427736", + "sha256:3262c96a1ca437e7e4763e2843746588a965426550f3797a79fca9c6199c431f", + "sha256:326420cbb492172dec84b0f65c80942de6cedb5233c413dd824483989c000608", + "sha256:4474f8ea030b5127225b8894d626bb66c01cda098d47a2b0d3429b6700af9fd8", + "sha256:592766c6303207a20efc445587778322d7f73b161bd994f227adaa341ba212ab", + "sha256:5ac82e411044fb129bae5cfbeb3ba626acb2af31a8d17d175004b70862a741a7", + "sha256:5f84523c076ad14ff5e6c037fe1c89a7f73a3e04cf0377cb4d017014976433f3", + "sha256:827dc04b8fa7d07c44de11fabbc888e627fa8293b695e0f99cb544fdfa1bf0d1", + "sha256:b4c423ab23291d3945ac61346feeb9a0dc4184999ede5e7c43e1ffb975130ae6", + "sha256:bc6bced57f826ca7cb5125a10b23fd0f2fff3b7c4701d64c439a300ce665fff8", + "sha256:c01b880ec30b5a6e6aa67b09a2fe3fb30473008c85cd6a67359a1b15ed6d83a4", + "sha256:ca233c64c6e40eaa6c66ef97058cdc80e8d0157a443655baa1b2966e812807ca", + "sha256:e863072cdf4c72eebf179342c94e6989c67185842d9997960b3e69290b2fa269" + ], + "version": "==3.12" + }, "recommonmark": { "hashes": [ "sha256:6e29c723abcf5533842376d87c4589e62923ecb6002a8e059eb608345ddaff9d", @@ -304,10 +365,10 @@ }, "tqdm": { "hashes": [ - "sha256:05e991ecb0f874046ddcb374396a626afd046fb4d31f73633ea752b844458a7a", - "sha256:2aea9f81fdf127048667e0ba22f5fc10ebc879fb838dc52dcf055242037ec1f7" + "sha256:4f2eb1d14804caf7095500fe11da0e481a47af912e7b57c93f886ac3c40a49dd", + "sha256:91ac47ec2ba6bb92b7ba37706f4dea37019ddd784b22fd279a4b12d93327191d" ], - "version": "==4.19.8" + "version": "==4.20.0" }, "twine": { "hashes": [ @@ -346,6 +407,13 @@ "sha256:cc44da8e1145637334317feebd728bd869a35285b93cbb4cca2577da7e62db4f" ], "version": "==1.22" + }, + "virtualenv": { + "hashes": [ + "sha256:1d7e241b431e7afce47e77f8843a276f652699d1fa4f93b9d8ce0076fd7b0b54", + "sha256:e8e05d4714a1c51a2f5921e62f547fcb0f713ebbe959e0a7f585cc8bef71d11f" + ], + "version": "==15.2.0" } } } diff --git a/README.md b/README.md index 87da205..dac918e 100644 --- a/README.md +++ b/README.md @@ -357,6 +357,28 @@ affect your use case. This can be used for example with PyCharm's [File Watchers](https://www.jetbrains.com/help/pycharm/file-watchers.html). +## Version control integration + +Use [pre-commit](https://pre-commit.com/). Once you [have it +installed](https://pre-commit.com/#install), add this to the +`.pre-commit-config.yaml` in your repository: +```yaml +repos: +- repo: https://github.com/ambv/black + rev: stable + hooks: + - id: black + args: [--line-length=88, --safe] + python-version: python3.6 +``` +Then run `pre-commit install` and you're ready to go. + +`args` in the above config is optional but shows you how you can change +the line length if you really need to. If you're already using Python +3.7, switch the `python-version` accordingly. Finally, `stable` is a tag +that is pinned to the latest release on PyPI. If you'd rather run on +master, this is also an option. + ## Testimonials **Dusty Phillips**, [writer](https://smile.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=dusty+phillips):