# HG changeset patch # User FUJIWARA Katsunori # Date 2015-05-17 17:52:58 # Node ID 10e6c4b7121b94d0b70552cf8c8ea1d7531a618a # Parent 86298718b01cfb1652e067f6af53ac049e14e4c0 import-checker: don't treat modules as relative one if not found The previous patch ensures all module names are recorded in `imports` as absolute names, so we no longer need to treat modules as ones imported relatively from the target source if they appear to not be from the stdlib. diff --git a/contrib/import-checker.py b/contrib/import-checker.py --- a/contrib/import-checker.py +++ b/contrib/import-checker.py @@ -293,8 +293,6 @@ def checkmod(mod, imports): while visit: path = visit.pop(0) for i in sorted(imports.get(path[-1], [])): - if i not in stdlib_modules and not i.startswith('mercurial.'): - i = mod.rsplit('.', 1)[0] + '.' + i if len(path) < shortest.get(i, 1000): shortest[i] = len(path) if i in path: @@ -316,10 +314,12 @@ def rotatecycle(cycle): def find_cycles(imports): """Find cycles in an already-loaded import graph. - >>> imports = {'top.foo': ['bar', 'os.path', 'qux'], - ... 'top.bar': ['baz', 'sys'], - ... 'top.baz': ['foo'], - ... 'top.qux': ['foo']} + All module names recorded in `imports` should be absolute one. + + >>> imports = {'top.foo': ['top.bar', 'os.path', 'top.qux'], + ... 'top.bar': ['top.baz', 'sys'], + ... 'top.baz': ['top.foo'], + ... 'top.qux': ['top.foo']} >>> print '\\n'.join(sorted(find_cycles(imports))) top.bar -> top.baz -> top.foo -> top.bar top.foo -> top.qux -> top.foo