]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
hacking: Fix false positive in C302 check
authorVictor Stinner <vstinner@redhat.com>
Tue, 9 Feb 2016 13:56:51 +0000 (14:56 +0100)
committerVictor Stinner <vstinner@redhat.com>
Tue, 9 Feb 2016 13:58:46 +0000 (14:58 +0100)
Use a regular expression to search for "unicode(" instead of a static
string to not complain to "exception_to_unicode(error)".

Change-Id: I0a969b184054f287cef463bbcb980bfb4a0a6803

cinder/hacking/checks.py

index 52ff7b7bf4506755591bf6b6e1e3f5eb47683fd0..7652ae655a8a2ecba9b44df2b23fa6279dbd196b 100644 (file)
@@ -400,13 +400,16 @@ def check_datetime_now(logical_line, noqa):
         yield(0, msg)
 
 
+_UNICODE_USAGE_REGEX = re.compile(r'\bunicode *\(')
+
+
 def check_unicode_usage(logical_line, noqa):
     if noqa:
         return
 
     msg = "C302: Found unicode() call. Please use six.text_type()."
 
-    if 'unicode(' in logical_line:
+    if _UNICODE_USAGE_REGEX.search(logical_line):
         yield(0, msg)