Skip to content

Commit 9112d40

Browse files
fix(scanner): ignore common dependency and environment directories by default (#3)
fix(scanner): ignore common dependency and environment directories by default (#3) Adds default ignores for common dependency, environment, build, and VCS directories to reduce noise when scanning repository roots. Ignored directories: .venv, venv, env, site-packages, __pycache__, dist, build, and .git. The ignore logic checks full path components to avoid accidental exclusion of valid source directories (e.g., "environment"). Documentation has been updated to reflect the new behavior and the version is bumped to 0.2.1.
1 parent 246b2a9 commit 9112d40

3 files changed

Lines changed: 23 additions & 3 deletions

File tree

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ pip install privlog
6565

6666
Once installed, you can run `privlog` against a specific path, or run it by itself to scan the current directory.
6767

68+
> **Note:** `privlog` automatically ignores common dependency and build directories (like `.venv`, `site-packages`, `build`, etc.) to reduce noise.
69+
6870
### Default (Errors Only)
6971

7072
By default, `privlog` only reports high-confidence `ERROR`s. If any are found, it will exit with a non-zero code, failing your build.
@@ -118,7 +120,7 @@ log_event = { details = "WARNING" }
118120

119121
## Status
120122

121-
Privlog is currently in early development (v0.2.0).
123+
Privlog is currently in early development (v0.2.1).
122124
Feedback and contributions are welcome.
123125

124126
---

privlog/ast_checks.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,27 @@ def visit_Call(self, node: ast.Call) -> None:
212212
self.generic_visit(node)
213213

214214

215+
DEFAULT_IGNORE_DIRS = {
216+
".venv",
217+
"venv",
218+
"env",
219+
"site-packages",
220+
"__pycache__",
221+
"dist",
222+
"build",
223+
".git",
224+
}
225+
215226
def run_ast_checks(root: Path, config: PrivlogConfig) -> list[AstFinding]:
216227
findings: list[AstFinding] = []
217-
for py in root.rglob("*.py"):
228+
229+
all_python_files = root.rglob("*.py")
230+
231+
for py in all_python_files:
232+
# Check if any parent directory component is in the ignore list
233+
if any(part in DEFAULT_IGNORE_DIRS for part in py.parts):
234+
continue
235+
218236
try:
219237
text = py.read_text(encoding="utf-8", errors="replace")
220238
tree = ast.parse(text)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "privlog"
7-
version = "0.2.0"
7+
version = "0.2.1"
88
description = "Privacy-aware logging hygiene linter for Python"
99
readme = "README.md"
1010
requires-python = ">=3.9"

0 commit comments

Comments
 (0)