From 458be54e27605a7cf7cd8240484e2f885ae1276d Mon Sep 17 00:00:00 2001 From: Travis Dart Date: Mon, 1 Jan 2024 08:12:10 -0500 Subject: [PATCH 01/11] Bugfix: Handle when .gitignore is not present. (#346) --- CHANGELOG.md | 1 + vulture/core.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 28b0693b..e8177a30 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ * 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). +* Properly detect when no .gitignore is present (travisdart, #346). # 2.10 (2023-10-06) diff --git a/vulture/core.py b/vulture/core.py index b118aab3..39f85982 100644 --- a/vulture/core.py +++ b/vulture/core.py @@ -116,7 +116,7 @@ def _ignore_variable(filename, varname): def _get_gitignore_pathspec(): - if (gitignore := Path(".gitignore").resolve()).is_file: + if (gitignore := Path(".gitignore").resolve()).is_file(): with gitignore.open() as fh: return PathSpec.from_lines("gitwildmatch", fh) return PathSpec.from_lines("gitwildmatch", []) From e20349b13fdc61659607d6333e39b20f4e3e833f Mon Sep 17 00:00:00 2001 From: Jendrik Seipp Date: Sat, 6 Jan 2024 19:54:58 +0100 Subject: [PATCH 02/11] Revert "Read exclude patterns from .gitignore in absence of user-provided patterns (#344) (#345)" This reverts commit aa6fcd281d2a6f963a99ee6f3c5055876f5a54f5. After further thought, the --exclude flag and .gitignore file have different responsibilities and mixing them will surprise some users. --- CHANGELOG.md | 2 -- README.md | 4 --- requirements.txt | 1 - tests/test_gitignore_patterns.py | 56 -------------------------------- vulture/core.py | 17 +--------- 5 files changed, 1 insertion(+), 79 deletions(-) delete mode 100644 tests/test_gitignore_patterns.py diff --git a/CHANGELOG.md b/CHANGELOG.md index e8177a30..d9ec6de8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,8 +2,6 @@ * 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). -* Properly detect when no .gitignore is present (travisdart, #346). # 2.10 (2023-10-06) diff --git a/README.md b/README.md index e531d8ef..99b2ec81 100644 --- a/README.md +++ b/README.md @@ -83,10 +83,6 @@ 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