From 7304ea42af97d14ecebe64a18481ac35ea29f578 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Robert?= Date: Wed, 13 Jan 2021 19:03:11 +0100 Subject: [PATCH 01/11] maint: add a pre-commit hook config file --- .pre-commit-hooks.yaml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .pre-commit-hooks.yaml diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml new file mode 100644 index 00000000..ea5a4fbb --- /dev/null +++ b/.pre-commit-hooks.yaml @@ -0,0 +1,6 @@ +- id: vulture + name: vulture + language: python + entry: vulture + description: Finds unused code in Python. + files: '(.py)$' From e71ce27a059e5c07d8edff9687493178317e39f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Robert?= Date: Wed, 13 Jan 2021 19:12:13 +0100 Subject: [PATCH 02/11] add changelog entry --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f650c6e..e5cd4977 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ * Don't override paths in pyproject.toml with empty CLI paths (bcbnz, #228). * Run continuous integration tests for Python 3.9 (ju-sh, #232). * Use pathlib internally (ju-sh, #226). - +* Make vulture usable with pre-commit (Clément Robert #244) # 2.1 (2020-08-19) * Treat `getattr/hasattr(obj, "constant_string", ...)` as a reference to From 7e3c23387148ac86b5e847cc2d9cd1e850df2512 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Robert?= Date: Wed, 13 Jan 2021 19:14:46 +0100 Subject: [PATCH 03/11] add install doc to readme --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 8642aed3..4841119c 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,14 @@ tool for higher code quality. $ pip install vulture +### as a pre-commit hook +Add this to your `.pre-commit-config.yaml` + + - repo: https://github.com/jendrikseipp/vulture + rev: 2.2 + hooks: + - id: vulture + ## Usage $ vulture myscript.py # or From 7ae61c761203d2ea61ae4bde41866520f87561e3 Mon Sep 17 00:00:00 2001 From: Jendrik Seipp Date: Wed, 13 Jan 2021 19:58:17 +0100 Subject: [PATCH 04/11] Filter files by type instead of regex. --- .pre-commit-hooks.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index ea5a4fbb..598702b9 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -1,6 +1,6 @@ -- id: vulture - name: vulture - language: python - entry: vulture - description: Finds unused code in Python. - files: '(.py)$' +- id: vulture + name: vulture + language: python + entry: vulture + description: Find unused Python code. + types: [python] From d484aee72751bd786982b899dda7e4ee8348c1d5 Mon Sep 17 00:00:00 2001 From: Jendrik Seipp Date: Wed, 13 Jan 2021 19:59:47 +0100 Subject: [PATCH 05/11] Update CHANGELOG.md --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e5cd4977..a50ef616 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,8 @@ * Don't override paths in pyproject.toml with empty CLI paths (bcbnz, #228). * Run continuous integration tests for Python 3.9 (ju-sh, #232). * Use pathlib internally (ju-sh, #226). -* Make vulture usable with pre-commit (Clément Robert #244) +* Add [pre-commit](https://pre-commit.com) hook (Clément Robert #244). + # 2.1 (2020-08-19) * Treat `getattr/hasattr(obj, "constant_string", ...)` as a reference to From e837b8beaac8c04f89522d7ca8900ea7eddbb73f Mon Sep 17 00:00:00 2001 From: Jendrik Seipp Date: Wed, 13 Jan 2021 20:06:55 +0100 Subject: [PATCH 06/11] Update README.md --- README.md | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 4841119c..519e7548 100644 --- a/README.md +++ b/README.md @@ -24,13 +24,20 @@ tool for higher code quality. $ pip install vulture -### as a pre-commit hook -Add this to your `.pre-commit-config.yaml` +### Version control integration + +After installing [pre-commit](https://pre-commit.com/#install), add the +following to the `.pre-commit-config.yaml` file in your repository: + +```yaml +repos: + - repo: https://github.com/jendrikseipp/vulture + rev: 2.2 + hooks: + - id: vulture +``` - - repo: https://github.com/jendrikseipp/vulture - rev: 2.2 - hooks: - - id: vulture +Then run `pre-commit install`. ## Usage From 8e76b340eadc800cf4e51fbcf49ab7cbcb93858d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Robert?= Date: Wed, 13 Jan 2021 20:30:11 +0100 Subject: [PATCH 07/11] add require_serial flag to turn off multiple instances of vulture, and pass_files: false so that vulture can detect files itself --- .pre-commit-hooks.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index 598702b9..ded2c877 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -4,3 +4,5 @@ entry: vulture description: Find unused Python code. types: [python] + pass_filenames: false + require_serial: true \ No newline at end of file From d5022e76769e9e6a854db957d99d241725e8d8e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Robert?= Date: Fri, 15 Jan 2021 19:44:48 +0100 Subject: [PATCH 08/11] update readme --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 519e7548..0b657e77 100644 --- a/README.md +++ b/README.md @@ -25,20 +25,21 @@ tool for higher code quality. $ pip install vulture ### Version control integration - + After installing [pre-commit](https://pre-commit.com/#install), add the following to the `.pre-commit-config.yaml` file in your repository: ```yaml repos: - repo: https://github.com/jendrikseipp/vulture - rev: 2.2 + rev: 2.3 hooks: - id: vulture ``` -Then run `pre-commit install`. - +Then run `pre-commit install`. In order to run Vulture before each commit, you will also +need to specify all files that should be checked in the `pyproject.toml` file under the +`paths` key. ## Usage $ vulture myscript.py # or From 6d13d9cb08afa563a11caa7b34f033115e83decc Mon Sep 17 00:00:00 2001 From: Jendrik Seipp Date: Fri, 15 Jan 2021 23:12:57 +0100 Subject: [PATCH 09/11] Add newline at end of file. --- .pre-commit-hooks.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index ded2c877..8d2df77e 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -5,4 +5,5 @@ description: Find unused Python code. types: [python] pass_filenames: false - require_serial: true \ No newline at end of file + require_serial: true + From 0cd496507e62d489de3596b36785d81090b63783 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Robert?= Date: Fri, 15 Jan 2021 23:50:32 +0100 Subject: [PATCH 10/11] add missing empty line to readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 0b657e77..50fa9831 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,7 @@ repos: Then run `pre-commit install`. In order to run Vulture before each commit, you will also need to specify all files that should be checked in the `pyproject.toml` file under the `paths` key. + ## Usage $ vulture myscript.py # or From 594d6a226a0e6b765137449870f52b7eccdb527c Mon Sep 17 00:00:00 2001 From: Jendrik Seipp Date: Sat, 16 Jan 2021 08:58:20 +0100 Subject: [PATCH 11/11] Update CHANGELOG.md --- CHANGELOG.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 151987e6..4bf48455 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,13 @@ +# unreleased + +* Add [pre-commit](https://pre-commit.com) hook (Clément Robert #244). + # 2.2 (2021-01-15) * Only parse format strings when being used with `locals()` (jingw, #225). * Don't override paths in pyproject.toml with empty CLI paths (bcbnz, #228). * Run continuous integration tests for Python 3.9 (ju-sh, #232). * Use pathlib internally (ju-sh, #226). -* Add [pre-commit](https://pre-commit.com) hook (Clément Robert #244). # 2.1 (2020-08-19)