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.
This commit is contained in:
John Watson 2013-01-08 20:33:50 -08:00
parent 264bc0370a
commit 0d3cc25400

View file

@ -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'):