Commits

Gustavo Picon  committed 165dce2

Fixed the W402 (imported but unused) bug in flake8's fork of pyflakes.

Added a couple of tests that fail without this patch.

  • Participants
  • Parent commits ca386cc

Comments (0)

Files changed (2)

File flake8/pyflakes.py

             self.addBinding(node.lineno, Assignment(name, node))
 
         def runException():
-            for stmt in node.body:
+            for stmt in iter_child_nodes(node):
                 self.handleNode(stmt, node)
 
         self.deferFunction(runException)

File flake8/tests/test_flakes.py

     print("err")
 """
 
+code_from_import_exception = """
+from foo import SomeException
+try:
+    pass
+except SomeException:
+    print("err")
+"""
+
+code_import_exception = """
+import foo.SomeException
+try:
+    pass
+except foo.SomeException:
+    print("err")
+"""
 
 class TestFlake(TestCase):
 
         for c in (code, code2, code3):
             warnings = check(code)
             self.assertEqual(warnings, 0, code)
+
+    def test_from_import_exception_in_scope(self):
+        self.assertEqual(check(code_from_import_exception), 0)
+
+    def test_import_exception_in_scope(self):
+        self.assertEqual(check(code_import_exception), 0)