From aa6fcd281d2a6f963a99ee6f3c5055876f5a54f5 Mon Sep 17 00:00:00 2001 From: Hussein Faara Date: Sat, 23 Dec 2023 08:27:09 -0800 Subject: [PATCH] Read exclude patterns from .gitignore in absence of user-provided patterns (#344) (#345) * 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. * Move dependencies to requirements.txt. --------- Co-authored-by: Jendrik Seipp --- .github/workflows/main.yml | 1 + CHANGELOG.md | 1 + README.md | 4 +++ requirements.txt | 2 ++ setup.py | 5 ++- tests/test_gitignore_patterns.py | 56 ++++++++++++++++++++++++++++++++ vulture/core.py | 17 +++++++++- 7 files changed, 84 insertions(+), 2 deletions(-) create mode 100644 requirements.txt create mode 100644 tests/test_gitignore_patterns.py diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 301e24e5..676614d3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -31,6 +31,7 @@ jobs: run: | python -m pip install --upgrade pip python -m pip install --upgrade build coveralls setuptools tox wheel + python -m pip install -r requirements.txt - name: Build Vulture wheel run: python -m build diff --git a/CHANGELOG.md b/CHANGELOG.md index d9ec6de8..28b0693b 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 (whosayn, #344, #345). # 2.10 (2023-10-06) diff --git a/README.md b/README.md index 99b2ec81..e531d8ef 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. +Vulture 2.11+ parses the `.gitignore` file in the current working directory for +exclude patterns if the `--exclude` parameter is unused and if there are no +exclude patterns in the pyproject.toml file. + #### Flake8 noqa comments