[PATCH 02 of 21 WIP-PY3K] encoding: convert to absolute_import

Gregory Szorc gregory.szorc at gmail.com
Mon Oct 12 17:22:32 CDT 2015


On Mon, Oct 12, 2015 at 2:24 PM, Matthew Turk <matthewturk at gmail.com> wrote:

> # HG changeset patch
> # User Matthew Turk <matthewturk at gmail.com>
> # Date 1444683043 18000
> #      Mon Oct 12 15:50:43 2015 -0500
> # Node ID c1ea4c8067b55e113c901c958d1857a1415d74dc
> # Parent  011e94a1c340f8dd335736cba51c126c909c935c
> encoding: convert to absolute_import
>
> diff -r 011e94a1c340 -r c1ea4c8067b5 mercurial/encoding.py
> --- a/mercurial/encoding.py     Mon Oct 12 15:46:49 2015 -0500
> +++ b/mercurial/encoding.py     Mon Oct 12 15:50:43 2015 -0500
> @@ -5,8 +5,13 @@
>  # This software may be used and distributed according to the terms of the
>  # GNU General Public License version 2 or any later version.
>
> -import error
> -import unicodedata, locale, os
> +from __future__ import absolute_import
> +
> +from . import (
> +    error
> +)
> +
> +import unicodedata, locale, os, sys
>

When you add absolute_import to a file, it triggers a strict static
analysis check for how import statements should be formatted. This is
described at
https://selenic.com/repo/hg/file/tip/contrib/import-checker.py#l318. This
patch doesn't follow those requirements (need 1 line per module). You can
run the checks via test-module-imports.t.

Please note there is an unfiled bug in the import checker around handling
of files in hgext/ and possibly in mercurial/hgweb (any mercurial/
subdirectory) as well. Basically, the import check screams when it
shouldn't.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20151012/4cbd7d66/attachment.html>


More information about the Mercurial-devel mailing list