diff --git a/lib/python/pyflyby/_autoimp.py b/lib/python/pyflyby/_autoimp.py index 4ab44033..73c5ffcf 100644 --- a/lib/python/pyflyby/_autoimp.py +++ b/lib/python/pyflyby/_autoimp.py @@ -575,6 +575,11 @@ def _NewScopeCtx(self, **kwargs): try: yield finally: + logger.debug("throwing last scope from scopestack: %r", new_scopestack[-1]) + for name, use_checker in new_scopestack[-1].items(): + if use_checker and use_checker.used == False: + logger.debug("unused checker %r ", use_checker) + self.unused_imports.append((use_checker.lineno, use_checker.source)) assert self.scopestack is new_scopestack self.scopestack = prev_scopestack