[PATCH 8 of 8] import-checker: handle iter/iterkeys+iteritems python3 divergence
Yuya Nishihara
yuya at tcha.org
Thu Mar 31 10:53:51 EDT 2016
On Wed, 30 Mar 2016 04:24:08 -0500, timeless wrote:
> # HG changeset patch
> # User timeless <timeless at mozdev.org>
> # Date 1459325737 0
> # Wed Mar 30 08:15:37 2016 +0000
> # Node ID 482080eea4493ba6616f30b5c38ce5d659bda513
> # Parent b0d9bcd93d81e0683d8c980273055f9f4289a9b4
> import-checker: handle iter/iterkeys+iteritems python3 divergence
>
> diff --git a/contrib/import-checker.py b/contrib/import-checker.py
> --- a/contrib/import-checker.py
> +++ b/contrib/import-checker.py
> @@ -702,7 +702,7 @@
> top.foo -> top.qux -> top.foo
> """
> cycles = set()
> - for mod in sorted(imports.iterkeys()):
> + for mod in sorted(imports.keys()):
> try:
> checkmod(mod, imports)
> except CircularImport as e:
> @@ -726,7 +726,7 @@
> for source_path in argv[1:]:
> modname = dotted_name_of_path(source_path, trimpure=True)
> localmods[modname] = source_path
> - for modname, source_path in sorted(localmods.iteritems()):
> + for modname, source_path in sorted(localmods.items()):
> f = open(source_path)
> src = f.read()
> used_imports[modname] = sorted(
> diff --git a/tests/test-check-module-imports.t b/tests/test-check-module-imports.t
> --- a/tests/test-check-module-imports.t
> +++ b/tests/test-check-module-imports.t
> @@ -141,6 +141,113 @@
> hidden by deduplication algorithm in the cycle detector, so fixing
> these may expose other cycles.
>
> +#if no-py3k
> $ hg locate 'mercurial/**.py' 'hgext/**.py' | sed 's-\\-/-g' | python "$import_checker" -
> Import cycle: hgext.largefiles.basestore -> hgext.largefiles.localstore -> hgext.largefiles.basestore
> [1]
> +#else
> + $ hg locate 'mercurial/**.py' 'hgext/**.py' | sed 's-\\-/-g' | python "$import_checker" -
> + hgext/eol.py:95: imports from mercurial not lexically sorted: config < util
Queued this, but dropped the test change. It should be covered by
test-check-py3-compat.t, and import-checker.py tries to stop generating
too much warnings if absolute_import is off.
More information about the Mercurial-devel
mailing list