From 0845300d1993ca749f0e661ad744ccb721c87e7c Mon Sep 17 00:00:00 2001 From: Marc Koderer Date: Fri, 1 Jan 2016 20:03:45 +0100 Subject: [PATCH] Fix issue with flake8 check and full paths Currently hacking check_explicit_underscore_import is dependent on a relative file path. A call of "flake8 ." works fine but "flake8 $PWD" doesn't which shouldn't be any difference. Change-Id: I7d40bbb771f96d28db38db69939de5e5993f3e9b Closes-bug: #1530460 --- cinder/hacking/checks.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/cinder/hacking/checks.py b/cinder/hacking/checks.py index fdbf1c4c0..fe9e11626 100644 --- a/cinder/hacking/checks.py +++ b/cinder/hacking/checks.py @@ -32,7 +32,7 @@ Guidelines for writing new hacking checks """ # NOTE(thangp): Ignore N323 pep8 error caused by importing cinder objects -UNDERSCORE_IMPORT_FILES = ['./cinder/objects/__init__.py'] +UNDERSCORE_IMPORT_FILES = ['cinder/objects/__init__.py'] translated_log = re.compile( r"(.)*LOG\.(audit|error|info|warn|warning|critical|exception)" @@ -161,10 +161,11 @@ def check_explicit_underscore_import(logical_line, filename): # Build a list of the files that have _ imported. No further # checking needed once it is found. - if filename in UNDERSCORE_IMPORT_FILES: - pass - elif (underscore_import_check.match(logical_line) or - custom_underscore_check.match(logical_line)): + for file in UNDERSCORE_IMPORT_FILES: + if file in filename: + return + if (underscore_import_check.match(logical_line) or + custom_underscore_check.match(logical_line)): UNDERSCORE_IMPORT_FILES.append(filename) elif(translated_log.match(logical_line) or string_translation.match(logical_line)): -- 2.45.2