]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Fix issue with flake8 check and full paths
authorMarc Koderer <marc@koderer.com>
Fri, 1 Jan 2016 19:03:45 +0000 (20:03 +0100)
committerMarc Koderer <marc@koderer.com>
Fri, 1 Jan 2016 19:03:45 +0000 (20:03 +0100)
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

index fdbf1c4c0c01d481ce93dd0af3d81899efb45570..fe9e11626f1b022a9e29335a298f8f0e56e8c042 100644 (file)
@@ -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)):