[PATCH] import-checker: report local with stdlib late warning

Yuya Nishihara yuya at tcha.org
Fri Mar 4 09:04:35 EST 2016


On Thu, 3 Mar 2016 22:34:51 -0800, Gregory Szorc wrote:
> > On Mar 2, 2016, at 07:48, timeless <timeless at mozdev.org> wrote:
> > 
> > # HG changeset patch
> > # User timeless <timeless at mozdev.org>
> > # Date 1456933134 0
> > #      Wed Mar 02 15:38:54 2016 +0000
> > # Node ID 74f6a6f4a9c82222044059cce91d8bda283e9989
> > # Parent  c7f89ad87baef87f00c507545dfd4cc824bc3131
> > import-checker: report local with stdlib late warning
> > 
> > Without this, developers have to figure it out on their own
> > 
> > diff --git a/contrib/import-checker.py b/contrib/import-checker.py
> > --- a/contrib/import-checker.py
> > +++ b/contrib/import-checker.py
> > @@ -366,7 +366,7 @@
> >     fromlocal = fromlocalfunc(module, localmods)
> > 
> >     # Whether a local/non-stdlib import has been performed.
> > -    seenlocal = False
> > +    seenlocal = None
> >     # Whether a relative, non-symbol import has been seen.
> >     seennonsymbolrelative = False
> >     # The last name to be imported (for sorting).
> > @@ -402,11 +402,14 @@
> > 
> >             # stdlib imports should be before local imports.
> >             stdlib = name in stdlib_modules
> > -            if stdlib and seenlocal and node.col_offset == root_col_offset:
> > -                yield msg('stdlib import follows local import: %s', name)
> > +            if (stdlib and seenlocal is not None and
> 
> I don't think you need the type compare on seenlocal here. Otherwise LGTM.

Dropped the strict type comparison and pushed to the clowncopter, thanks!


More information about the Mercurial-devel mailing list