[PATCH 3 of 8] import-checker: always build a list of imported symbols
Yuya Nishihara
yuya at tcha.org
Sat May 14 03:33:48 EDT 2016
# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1463199613 -32400
# Sat May 14 13:20:13 2016 +0900
# Node ID c227e9d4e8c137fd1dd67ebd6b21aae8dfab68d1
# Parent f9c6e835b650600d21846e5ce2cabf0ffc53da3c
import-checker: always build a list of imported symbols
The next patch will rely on it.
diff --git a/contrib/import-checker.py b/contrib/import-checker.py
--- a/contrib/import-checker.py
+++ b/contrib/import-checker.py
@@ -456,15 +456,14 @@ def verify_modern_convention(module, roo
# 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)
More information about the Mercurial-devel
mailing list