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

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

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 04 Nov 2015 15:38:02 +0100
changeset 4540
45627d092846
parent 4538
cbff7269b187
child 4543
2e6a880670e9

Fixed the futures checker raising false psitives when a file only contains a docstring.
(grafted from beac8323fa9ec75f814a9f3ad55d50480bfc2837)

Plugins/CheckerPlugins/CodeStyleChecker/MiscellaneousChecker.py file | annotate | diff | comparison | revisions
--- a/Plugins/CheckerPlugins/CodeStyleChecker/MiscellaneousChecker.py	Wed Nov 04 14:49:29 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