From 731ace6f661ab15718513dc11a3de27ceb79da03 Mon Sep 17 00:00:00 2001 From: Hussein Faara Date: Thu, 21 Dec 2023 22:40:52 -0800 Subject: [PATCH 01/10] Read exclude patterns from .gitignore in absence of user-provided patterns (#344) Use .gitignore to exclude files if --exclude is missing from both pyproject.toml and the command line. Vulture now requires the pathspec library to run. --- CHANGELOG.md | 1 + README.md | 4 +++ setup.py | 5 ++- tests/test_gitignore_patterns.py | 56 ++++++++++++++++++++++++++++++++ vulture/core.py | 17 +++++++++- 5 files changed, 81 insertions(+), 2 deletions(-) create mode 100644 tests/test_gitignore_patterns.py diff --git a/CHANGELOG.md b/CHANGELOG.md index d9ec6de8..aa4bc07e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ * Bump flake8, flake8-comprehensions and flake8-bugbear (Sebastian Csar, #341). * Switch to tomllib/tomli to support heterogeneous arrays (Sebastian Csar, #340). * Provide whitelist parity for `MagicMock` and `Mock` (maxrake). +* Use .gitignore to exclude files if --exclude is missing from both pyproject.toml and the command line. # 2.10 (2023-10-06) diff --git a/README.md b/README.md index 99b2ec81..981d9ef8 100644 --- a/README.md +++ b/README.md @@ -83,6 +83,10 @@ If you want to ignore a whole file or directory, use the `--exclude` parameter (e.g., `--exclude "*settings.py,*/docs/*.py,*/test_*.py,*/.venv/*.py"`). The exclude patterns are matched against absolute paths. +Note that releases after 2.10 will parse the project's .gitignore files for +exclude patterns if the `--exclude` parameter is unused and if there are no +exclude patterns in the pyproject.toml file. + #### Flake8 noqa comments