Fixed the futures checker raising false psitives when a file only contains a docstring. 6_1_x

Wed, 04 Nov 2015 15:38:02 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 04 Nov 2015 15:38:02 +0100
branch
6_1_x
changeset 4539
beac8323fa9e
parent 4537
ec6221550141
child 4541
e8ddd9d76414

Fixed the futures checker raising false psitives when a file only contains a docstring.

Plugins/CheckerPlugins/CodeStyleChecker/MiscellaneousChecker.py file | annotate | diff | comparison | revisions
--- a/Plugins/CheckerPlugins/CodeStyleChecker/MiscellaneousChecker.py	Wed Nov 04 14:47:53 2015 +0100
+++ b/Plugins/CheckerPlugins/CodeStyleChecker/MiscellaneousChecker.py	Wed Nov 04 15:38:02 2015 +0100
@@ -302,6 +302,7 @@
         
         imports = set()
         node = None
+        hasCode = False
         
         for node in ast.walk(self.__tree):
             if (isinstance(node, ast.ImportFrom) and
@@ -309,11 +310,13 @@
                 imports |= set(name.name for name in node.names)
             elif isinstance(node, ast.Expr):
                 if not isinstance(node.value, ast.Str):
+                    hasCode = True
                     break
-            elif not isinstance(node, ast.Module):
+            elif not isinstance(node, (ast.Module, ast.Str)):
+                hasCode = True
                 break
 
-        if isinstance(node, ast.Module):
+        if isinstance(node, ast.Module) or not hasCode:
             return
 
         if not (imports >= expectedImports):

eric ide

mercurial