Mercurial > hg-stable
changeset 32457:d02888308235
import-checker: add a way to directly import certain symbols
We'll use this for the 'demandimport' symbol in an upcoming patch.
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Sun, 21 May 2017 12:09:01 -0700 |
parents | 1651977596c0 |
children | 0906b85bf222 |
files | contrib/import-checker.py |
diffstat | 1 files changed, 7 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/contrib/import-checker.py Sun May 21 13:34:42 2017 -0700 +++ b/contrib/import-checker.py Sun May 21 12:09:01 2017 -0700 @@ -24,6 +24,9 @@ 'mercurial.node', ) +# Whitelist of symbols that can be directly imported. +directsymbols = () + # Modules that must be aliased because they are commonly confused with # common variables and can create aliasing and readability issues. requirealias = { @@ -464,10 +467,11 @@ 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)] + symbols = (n.name for n in node.names + if not fromlocal(prefix + n.name)) else: - symbols = [n.name for n in node.names] + symbols = (n.name for n in node.names) + symbols = [sym for sym in symbols if sym not in directsymbols] if node.module and node.col_offset == root_col_offset: if symbols and fullname not in allowsymbolimports: yield msg('direct symbol import %s from %s',