--- a/contrib/import-checker.py Thu Aug 31 11:28:59 2017 -0700
+++ b/contrib/import-checker.py Mon Aug 28 13:43:25 2017 -0700
@@ -411,7 +411,8 @@
assign the symbol to a module-level variable. In addition, these imports
must be performed before other local imports. This rule only
applies to import statements outside of any blocks.
- * Relative imports from the standard library are not allowed.
+ * Relative imports from the standard library are not allowed, unless that
+ library is also a local module.
* Certain modules must be aliased to alternate names to avoid aliasing
and readability problems. See `requirealias`.
"""
@@ -493,7 +494,10 @@
# __future__ is special since it needs to come first and use
# symbol import.
if fullname != '__future__':
- if not fullname or fullname in stdlib_modules:
+ if not fullname or (
+ fullname in stdlib_modules
+ and fullname not in localmods
+ and fullname + '.__init__' not in localmods):
yield msg('relative import of stdlib module')
else:
seenlocal = fullname