From c0794295e289398fc64af6412b84aca26c0fde27 Mon Sep 17 00:00:00 2001 From: Samir Boulahtit Date: Fri, 28 Nov 2025 19:47:57 +0100 Subject: [PATCH] fix: exclude venv and .venv from architecture validation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Update .architecture-rules.yaml to ignore venv/.venv directories - Improve _should_ignore_file() method to handle venv path exclusions - Add explicit checks for .venv/ and venv/ in file paths This prevents the architecture validator from scanning thousands of files in virtual environment directories, reducing validation time from scanning all dependency files to just project files. Before: Scanned venv files (thousands of violations in dependencies) After: Only scans project files (123 files checked) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .architecture-rules.yaml | 4 ++++ scripts/validate_architecture.py | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/.architecture-rules.yaml b/.architecture-rules.yaml index 73c62cb9..480a59ce 100644 --- a/.architecture-rules.yaml +++ b/.architecture-rules.yaml @@ -399,6 +399,10 @@ ignore: - "**/__pycache__/**" - "**/migrations/**" - "**/node_modules/**" + - "**/.venv/**" + - "**/venv/**" + - ".venv/**" + - "venv/**" patterns: # Allow HTTPException in specific files diff --git a/scripts/validate_architecture.py b/scripts/validate_architecture.py index a2587b12..55125df3 100755 --- a/scripts/validate_architecture.py +++ b/scripts/validate_architecture.py @@ -557,9 +557,18 @@ class ArchitectureValidator: """Check if file should be ignored""" ignore_patterns = self.config.get("ignore", {}).get("files", []) + # Convert to string for easier matching + file_path_str = str(file_path) + for pattern in ignore_patterns: + # Check if any part of the path matches the pattern if file_path.match(pattern): return True + # Also check if pattern appears in the path (for .venv, venv, etc.) + if "/.venv/" in file_path_str or file_path_str.startswith(".venv/"): + return True + if "/venv/" in file_path_str or file_path_str.startswith("venv/"): + return True return False