From 4d694a6e433e10e5c663a34366bda700949338f3 Mon Sep 17 00:00:00 2001 From: Jendrik Seipp Date: Sun, 8 Jan 2023 18:53:42 +0100 Subject: [PATCH] Clarify that --exclude patterns are matched against absolute paths to fix #260. --- CHANGELOG.md | 1 + README.md | 7 ++++--- vulture/config.py | 7 ++++--- vulture/utils.py | 6 +++--- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bc86f2aa..a42e2feb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ * Add whitelist for `socketserver.TCPServer.allow_reuse_address` (Ben Elliston) +* Clarify that `--exclude` patterns are matched against absolute paths (Jendrik Seipp, #260). # 2.6 (2022-09-19) diff --git a/README.md b/README.md index a1d67662..a6cc88e9 100644 --- a/README.md +++ b/README.md @@ -80,8 +80,9 @@ We collect whitelists for common Python modules and packages in #### Ignoring files -If you want to ignore a whole file or directory, use the `--exclude` -parameter (e.g., `--exclude *settings.py,docs/`). +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. #### Flake8 noqa comments @@ -174,7 +175,7 @@ Example Config: ``` toml [tool.vulture] -exclude = ["file*.py", "dir/"] +exclude = ["*file*.py", "dir/"] ignore_decorators = ["@app.route", "@require_*"] ignore_names = ["visit_*", "do_*"] make_whitelist = true diff --git a/vulture/config.py b/vulture/config.py index 8b72bca2..628bdb6e 100644 --- a/vulture/config.py +++ b/vulture/config.py @@ -109,9 +109,10 @@ def csv(exclude): metavar="PATTERNS", type=csv, default=missing, - help=f"Comma-separated list of paths to ignore (e.g.," - f' "*settings.py,docs/*.py"). {glob_help} A PATTERN without glob' - f" wildcards is treated as *PATTERN*.", + help=f"Comma-separated list of path patterns to ignore (e.g.," + f' "*settings.py,docs,*/test_*.py,venv"). {glob_help} A PATTERN without ' + f" glob wildcards is treated as *PATTERN*. Patterns are matched" + f" against absolute paths.", ) parser.add_argument( "--ignore-decorators", diff --git a/vulture/utils.py b/vulture/utils.py index 69ae0bd2..7bed9f93 100644 --- a/vulture/utils.py +++ b/vulture/utils.py @@ -67,9 +67,9 @@ def get_decorator_name(decorator): def get_modules(paths): """Retrieve Python files to check. - Loop over all given paths, abort if any ends with .pyc and add collect - the other given files (even those not ending with .py) and all .py - files under the given directories. + Loop over all given paths, abort if any ends with .pyc, add the other given + files (even those not ending with .py) and collect all .py files under the + given directories. """ modules = []