Commits

John Watson  committed 7158ae6

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.

  • Participants
  • Parent commits a38b3ed
  • Branches refactor

Comments (0)

Files changed (1)

File flake8/main.py

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