From 78e8165b06ada2a027f4c9976889bbe863c24cbd Mon Sep 17 00:00:00 2001 From: Ian Cordasco Date: Sat, 19 Nov 2016 08:21:36 -0600 Subject: [PATCH] Skip filename pattern check for provided files By default, when discovering files for users, we use the filename patterns to determine whether or not we should check that file. However, when a user provides the path to a file, we should instead skip checking the name against the filename patterns provided. For example, in Flake8 2.6 this worked: $ flake8 bin/script.py $ flake8 bin/script But prior to this commit only $ flake8 bin/script.py works. This commit will skip the filename pattern check if the user provides the path explicitly which allows $ flake8 bin/script to work again as expected. Closes #266 --- src/flake8/checker.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/flake8/checker.py b/src/flake8/checker.py index b4e22b2..cf25117 100644 --- a/src/flake8/checker.py +++ b/src/flake8/checker.py @@ -275,7 +275,14 @@ class Manager(object): for argument in paths for filename in utils.filenames_from(argument, self.is_path_excluded) - if should_create_file_checker(filename) + # NOTE(sigmavirus24): If a user explicitly specifies something, + # e.g, ``flake8 bin/script`` then we should run Flake8 against + # that. Since should_create_file_checker looks to see if the + # filename patterns match the filename, we want to skip that in + # the event that the argument and the filename are identical. + # If it was specified explicitly, the user intended for it to be + # checked. + if argument == filename or should_create_file_checker(filename) ] LOG.info('Checking %d files', len(self.checkers))