eric7/Plugins/CheckerPlugins/SyntaxChecker/pyflakes/checker.py

branch
eric7
changeset 8682
04e80d1aaebf
parent 8312
800c432b34c8
child 8881
54e42bc2437a
--- a/eric7/Plugins/CheckerPlugins/SyntaxChecker/pyflakes/checker.py	Tue Oct 12 19:54:03 2021 +0200
+++ b/eric7/Plugins/CheckerPlugins/SyntaxChecker/pyflakes/checker.py	Tue Oct 12 21:55:56 2021 +0200
@@ -282,7 +282,8 @@
             yield field
         elif isinstance(field, list):
             for item in field:
-                yield item
+                if isinstance(item, ast.AST):
+                    yield item
 
 
 def convert_to_value(item):
@@ -698,6 +699,8 @@
         return node.id
     if hasattr(node, 'name'):   # an ExceptHandler node
         return node.name
+    if hasattr(node, 'rest'):   # a MatchMapping node
+        return node.rest
 
 
 TYPING_MODULES = frozenset(('typing', 'typing_extensions'))
@@ -724,6 +727,16 @@
 
         return False
 
+    def _module_scope_is_typing(name):
+        for scope in reversed(scope_stack):
+            if name in scope:
+                return (
+                    isinstance(scope[name], Importation) and
+                    scope[name].fullName in TYPING_MODULES
+                )
+
+        return False
+
     return (
         (
             isinstance(node, ast.Name) and
@@ -731,7 +744,7 @@
         ) or (
             isinstance(node, ast.Attribute) and
             isinstance(node.value, ast.Name) and
-            node.value.id in TYPING_MODULES and
+            _module_scope_is_typing(node.value.id) and
             is_name_match_fn(node.attr)
         )
     )
@@ -875,7 +888,6 @@
 
     nodeDepth = 0
     offset = None
-    traceTree = False
     _in_annotation = AnnotationState.NONE
     _in_deferred = False
 
@@ -1400,8 +1412,6 @@
         if self.offset and getattr(node, 'lineno', None) is not None:
             node.lineno += self.offset[0]
             node.col_offset += self.offset[1]
-        if self.traceTree:
-            print('  ' * self.nodeDepth + node.__class__.__name__)
         if self.futuresAllowed and not (isinstance(node, ast.ImportFrom) or
                                         self.isDocstring(node)):
             self.futuresAllowed = False
@@ -1413,8 +1423,6 @@
             handler(node)
         finally:
             self.nodeDepth -= 1
-        if self.traceTree:
-            print('  ' * self.nodeDepth + 'end ' + node.__class__.__name__)
 
     _getDoctestExamples = doctest.DocTestParser().get_examples
 
@@ -2390,3 +2398,12 @@
             left = right
 
         self.handleChildren(node)
+
+    MATCH = MATCH_CASE = MATCHCLASS = MATCHOR = MATCHSEQUENCE = handleChildren
+    MATCHSINGLETON = MATCHVALUE = handleChildren
+
+    def _match_target(self, node):
+        self.handleNodeStore(node)
+        self.handleChildren(node)
+
+    MATCHAS = MATCHMAPPING = MATCHSTAR = _match_target

eric ide

mercurial