Commits

Brodie Rao  committed 5bc8ffa

Added support for ignoring unused imports directly inside try/except blocks

  • Participants
  • Parent commits 62515f1

Comments (0)

Files changed (2)

File pyflakes/checker.py

             # Look for imported names that aren't used.
             for importation in scope.values():
                 if isinstance(importation, Importation):
+                    # Ignore unused imports directly inside try/except blocks
+                    if isinstance(importation.source.parent, _ast.TryExcept):
+                        continue
                     if not importation.used and importation.name not in all:
                         self.report(
                             messages.UnusedImport,

File pyflakes/test/test_imports.py

         self.flakes('import fu; [fu, bar] = fu')
         self.flakes('import fu; fu += fu')
 
-    @skip("todo")
     def test_tryingMultipleImports(self):
         self.flakes('''
         try:
     def test_ignoreNonImportRedefinitions(self):
         self.flakes('a = 1; a = 2')
 
-    @skip("todo")
     def test_importingForImportError(self):
         self.flakes('''
         try: