From 0d3cc25400c771d3f7f24ef8bb3e6d585852b5c6 Mon Sep 17 00:00:00 2001 From: John Watson Date: Tue, 8 Jan 2013 20:33:50 -0800 Subject: [PATCH] Clear os.walk's dirnames to properly exclude dirs I have a project: `./foo/__init__.py` `./foo/bar/__init__.py` `./foo/baz.py` `./__init__.py` `./qux.py` Running: `flake8 --exclude="foo" ./` Checks: `./foo/bar/__init__.py` `./__init__.py` `./qux.py` This patch prevents the continued walking of **foo**'s subdirectories and not just files. --- flake8/main.py | 1 + 1 file changed, 1 insertion(+) diff --git a/flake8/main.py b/flake8/main.py index 9e462aa..faac93b 100644 --- a/flake8/main.py +++ b/flake8/main.py @@ -141,6 +141,7 @@ def _get_python_files(paths): if os.path.isdir(path): for dirpath, dirnames, filenames in os.walk(path): if pep8style.excluded(dirpath): + dirnames[:] = [] continue for filename in filenames: if not filename.endswith('.py'):