On 12/15/2016 05:36 PM, Augie Fackler wrote:
On Thu, Dec 15, 2016 at 11:32 AM, Augie Fackler <r...@durin42.com> wrote:
@@ -1,44 +1,52 @@
from __future__ import absolute_import, print_function
+import silenttestrunner
import struct
+import unittest
+
I got some weirdly inconsistent import-checking behavior out of these
lines on one machine, but can't reproduce it now. Given that this
looks very similar to the equivalent code in test-manifest.py, I'm not
going to sweat it.
Apparently the import check do not take in account the change between
stdlib / local when checking for lexical order. The following patch
seems to fix that. Do you want a formal patch on the list or should I
push that ?
diff --git a/contrib/import-checker.py b/contrib/import-checker.py
--- a/contrib/import-checker.py
+++ b/contrib/import-checker.py
@@ -391,6 +391,7 @@ def verify_modern_convention(module, roo
seennonsymbollocal = False
# The last name to be imported (for sorting).
lastname = None
+ laststdlib = None
# Relative import levels encountered so far.
seenlevels = set()
@@ -412,16 +413,18 @@ def verify_modern_convention(module, roo
name = node.names[0].name
asname = node.names[0].asname
+ stdlib = name in stdlib_modules
+
# Ignore sorting rules on imports inside blocks.
if node.col_offset == root_col_offset:
- if lastname and name < lastname:
+ if lastname and name < lastname and laststdlib == stdlib:
yield msg('imports not lexically sorted: %s < %s',
name, lastname)
- lastname = name
+ lastname = name
+ laststdlib = stdlib
# 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 "%s" follows local import: %s',
name, seenlocal)
diff --git a/tests/test-bdiff.py b/tests/test-bdiff.py
--- a/tests/test-bdiff.py
+++ b/tests/test-bdiff.py
@@ -1,8 +1,10 @@
from __future__ import absolute_import, print_function
-import silenttestrunner
+
import struct
import unittest
+import silenttestrunner
+
from mercurial import (
bdiff,
mpatch,
--
Pierre-Yves David
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel