Mercurial > hg
changeset 27273:5d5b98346fc2
import-checker: tell which symbol causes "direct symbol import"
This would be sometimes useful to understand why import-checker.py complains
about it.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 06 Dec 2015 14:28:35 +0900 |
parents | 69308357ecd1 |
children | 82910fdc216f |
files | contrib/import-checker.py tests/test-module-imports.t |
diffstat | 2 files changed, 5 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/contrib/import-checker.py Sun Dec 06 14:18:19 2015 +0900 +++ b/contrib/import-checker.py Sun Dec 06 14:28:35 2015 +0900 @@ -453,7 +453,8 @@ symbols = [n.name for n in node.names] if symbols and fullname not in allowsymbolimports: - yield msg('direct symbol import from %s', fullname) + yield msg('direct symbol import %s from %s', + ', '.join(symbols), fullname) if symbols and seennonsymbolrelative: yield msg('symbol import follows non-symbol import: %s',
--- a/tests/test-module-imports.t Sun Dec 06 14:18:19 2015 +0900 +++ b/tests/test-module-imports.t Sun Dec 06 14:28:35 2015 +0900 @@ -117,8 +117,8 @@ testpackage/importalias.py:2: ui module must be "as" aliased to uimod testpackage/importfromalias.py:2: ui from testpackage must be "as" aliased to uimod testpackage/importfromrelative.py:2: import should be relative: testpackage.unsorted - testpackage/importfromrelative.py:2: direct symbol import from testpackage.unsorted - testpackage/importsymbolfromsub.py:2: direct symbol import from testpackage.subpackage + testpackage/importfromrelative.py:2: direct symbol import foo from testpackage.unsorted + testpackage/importsymbolfromsub.py:2: direct symbol import nonmodule from testpackage.subpackage testpackage/latesymbolimport.py:3: symbol import follows non-symbol import: mercurial.node testpackage/multiple.py:2: multiple imported names: os, sys testpackage/multiplegroups.py:3: multiple "from . import" statements @@ -129,7 +129,7 @@ testpackage/subpackage/levelpriority.py:3: higher-level import should come first: testpackage testpackage/subpackage/localimport.py:7: multiple "from .. import" statements testpackage/subpackage/localimport.py:8: import should be relative: testpackage.subpackage.levelpriority - testpackage/symbolimport.py:2: direct symbol import from testpackage.unsorted + testpackage/symbolimport.py:2: direct symbol import foo from testpackage.unsorted testpackage/unsorted.py:3: imports not lexically sorted: os < sys [1]