import-checker: always build a list of imported symbols
authorYuya Nishihara <yuya@tcha.org>
Sat, 14 May 2016 13:20:13 +0900
changeset 29207 a09098c61fea
parent 29206 0ec8501af800
child 29208 cba8bc11ed10
import-checker: always build a list of imported symbols The next patch will rely on it.
contrib/import-checker.py
--- a/contrib/import-checker.py	Sat May 14 13:49:46 2016 +0900
+++ b/contrib/import-checker.py	Sat May 14 13:20:13 2016 +0900
@@ -456,15 +456,14 @@
 
             # Direct symbol import is only allowed from certain modules and
             # must occur before non-symbol imports.
+            found = fromlocal(node.module, node.level)
+            if found and found[2]:  # node.module is a package
+                prefix = found[0] + '.'
+                symbols = [n.name for n in node.names
+                           if not fromlocal(prefix + n.name)]
+            else:
+                symbols = [n.name for n in node.names]
             if node.module and node.col_offset == root_col_offset:
-                found = fromlocal(node.module, node.level)
-                if found and found[2]:  # node.module is a package
-                    prefix = found[0] + '.'
-                    symbols = [n.name for n in node.names
-                               if not fromlocal(prefix + n.name)]
-                else:
-                    symbols = [n.name for n in node.names]
-
                 if symbols and fullname not in allowsymbolimports:
                     yield msg('direct symbol import %s from %s',
                               ', '.join(symbols), fullname)