code: def checkDeadScopes(self):
          
          for scope in self.deadScopes:
              # imports in classes are public members
              if isinstance(scope, ClassScope):
                  continue
  
              all_binding = scope.get('__all__')
              if all_binding and not isinstance(all_binding, ExportBinding):
                  all_binding = None
  
              if all_binding:
                  all_names = set(all_binding.names)
                  undefined = all_names.difference(scope)
              else:
                  all_names = undefined = []
  
              if undefined:
                  if not scope.importStarred and \
                     os.path.basename(self.filename) != '__init__.py':
                      # Look for possible mistakes in the export list
                      for name in undefined:
                          self.report(messages.UndefinedExport,
                                      scope['__all__'].source, name)
  
                  # mark all import '*' as used by the undefined in __all__
                  if scope.importStarred:
                      from_list = []
                      for binding in scope.values():
                          if isinstance(binding, StarImportation):
                              binding.used = all_binding
                              from_list.append(binding.fullName)
                      # report * usage, with a list of possible sources
                      from_list = ', '.join(sorted(from_list))
                      for name in undefined:
                          self.report(messages.ImportStarUsage,
                                      scope['__all__'].source, name, from_list)
  
              # Look for imported names that aren't used.
              for value in scope.values():
                  if isinstance(value, Importation):
                      used = value.used or value.name in all_names
                      if not used:
                          messg = messages.UnusedImport
                          self.report(messg, value.source, str(value))
                      for node in value.redefined:
                          if isinstance(self.getParent(node), FOR_TYPES):
                              messg = messages.ImportShadowedByLoopVar
                          elif used:
                              continue
                          else:
                              messg = messages.RedefinedWhileUnused
                          self.report(messg, node, value.name, value.source)
docs: Look at scopes which have been fully examined and report names in them
          which were imported but unused.