Plugins/CheckerPlugins/SyntaxChecker/pyflakes/checker.py

changeset 5510
cdcd0cd34e79
parent 5389
9b1c800daff3
child 6048
82ad8ec9548c
diff -r d4c4763b46ee -r cdcd0cd34e79 Plugins/CheckerPlugins/SyntaxChecker/pyflakes/checker.py
--- a/Plugins/CheckerPlugins/SyntaxChecker/pyflakes/checker.py	Wed Feb 08 21:36:29 2017 +0100
+++ b/Plugins/CheckerPlugins/SyntaxChecker/pyflakes/checker.py	Wed Feb 08 21:39:58 2017 +0100
@@ -311,7 +311,7 @@
 
 
 class StarImportation(Importation):
-    """A binding created by an 'from x import *' statement."""
+    """A binding created by a 'from x import *' statement."""
 
     def __init__(self, name, source):
         super(StarImportation, self).__init__('*', source)
@@ -806,7 +806,7 @@
             return
 
         if on_conditional_branch():
-            # We can not predict if this conditional branch is going to
+            # We cannot predict if this conditional branch is going to
             # be executed.
             return
 
@@ -944,7 +944,7 @@
         MATMULT = ignore
 
     # additional node types
-    COMPREHENSION = KEYWORD = FORMATTEDVALUE = handleChildren
+    COMPREHENSION = KEYWORD = FORMATTEDVALUE = JOINEDSTR = handleChildren
 
     def DICT(self, node):
         # Complain if there are duplicate keys with different values
@@ -1328,7 +1328,7 @@
         self.handleNodeStore(node)
         self.handleChildren(node)
         if not is_name_previously_defined:
-            # See discussion on https://github.com/pyflakes/pyflakes/pull/59.
+            # See discussion on https://github.com/PyCQA/pyflakes/pull/59
 
             # We're removing the local name since it's being unbound
             # after leaving the except: block and it's always unbound
@@ -1343,5 +1343,24 @@
             except KeyError:
                 pass
 
+    def ANNASSIGN(self, node):
+        """
+        Annotated assignments don't have annotations evaluated on function
+        scope, hence the custom implementation.
+
+        See: PEP 526.
+        """
+        if node.value:
+            # Only bind the *targets* if the assignment has a value.
+            # Otherwise it's not really ast.Store and shouldn't silence
+            # UndefinedLocal warnings.
+            self.handleNode(node.target, node)
+        if not isinstance(self.scope, FunctionScope):
+            self.handleNode(node.annotation, node)
+        if node.value:
+            # If the assignment has value, handle the *value* now.
+            self.handleNode(node.value, node)
+
+
 #
 # eflag: noqa = M702

eric ide

mercurial