mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-03 19:56:54 +00:00
Search current directory if no paths are specified
This fixes a regression in behaviour from 2.x to 3. Closes #150
This commit is contained in:
parent
790549fd25
commit
b194717d1a
4 changed files with 27 additions and 7 deletions
|
|
@ -253,6 +253,10 @@ class Manager(object):
|
|||
"""Create checkers for each file."""
|
||||
if paths is None:
|
||||
paths = self.arguments
|
||||
|
||||
if not paths:
|
||||
paths = ['.']
|
||||
|
||||
filename_patterns = self.options.filename
|
||||
|
||||
# NOTE(sigmavirus24): Yes this is a little unsightly, but it's our
|
||||
|
|
@ -273,6 +277,7 @@ class Manager(object):
|
|||
self.is_path_excluded)
|
||||
if should_create_file_checker(filename)
|
||||
]
|
||||
LOG.info('Checking %d files', len(self.checkers))
|
||||
|
||||
def report(self):
|
||||
# type: () -> (int, int)
|
||||
|
|
@ -340,6 +345,9 @@ class Manager(object):
|
|||
raise
|
||||
LOG.warning('Running in serial after OS exception, %r', oserr)
|
||||
self.run_serial()
|
||||
except KeyboardInterrupt:
|
||||
LOG.warning('Flake8 was interrupted by the user')
|
||||
raise exceptions.EarlyQuit('Early quit while running checks')
|
||||
|
||||
def start(self, paths=None):
|
||||
"""Start checking files.
|
||||
|
|
|
|||
|
|
@ -7,6 +7,12 @@ class Flake8Exception(Exception):
|
|||
pass
|
||||
|
||||
|
||||
class EarlyQuit(Flake8Exception):
|
||||
"""Except raised when encountering a KeyboardInterrupt."""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class FailedToLoadPlugin(Flake8Exception):
|
||||
"""Exception raised when a plugin fails to load."""
|
||||
|
||||
|
|
|
|||
|
|
@ -209,16 +209,22 @@ def filenames_from(arg, predicate=None):
|
|||
predicate = _default_predicate
|
||||
if os.path.isdir(arg):
|
||||
for root, sub_directories, files in os.walk(arg):
|
||||
for filename in files:
|
||||
joined = os.path.join(root, filename)
|
||||
if predicate(joined):
|
||||
continue
|
||||
yield joined
|
||||
if predicate(root):
|
||||
sub_directories[:] = []
|
||||
continue
|
||||
|
||||
# NOTE(sigmavirus24): os.walk() will skip a directory if you
|
||||
# remove it from the list of sub-directories.
|
||||
for directory in sub_directories:
|
||||
if predicate(directory):
|
||||
joined = os.path.join(root, directory)
|
||||
if predicate(directory) or predicate(joined):
|
||||
sub_directories.remove(directory)
|
||||
|
||||
for filename in files:
|
||||
joined = os.path.join(root, filename)
|
||||
if predicate(joined) or predicate(filename):
|
||||
continue
|
||||
yield joined
|
||||
else:
|
||||
yield arg
|
||||
|
||||
|
|
|
|||
2
tox.ini
2
tox.ini
|
|
@ -132,7 +132,7 @@ ignore = D203
|
|||
# NOTE(sigmavirus24): Once we release 3.0.0 this exclude option can be specified
|
||||
# across multiple lines. Presently it cannot be specified across multiple lines.
|
||||
# :-(
|
||||
exclude = .git,__pycache__,docs/source/conf.py,old,build,dist,tests/fixtures/
|
||||
exclude = .tox,.git,__pycache__,docs/source/conf.py,build,dist,tests/fixtures/*,*.pyc
|
||||
max-complexity = 10
|
||||
import-order-style = google
|
||||
application-import-names = flake8
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue