# HG changeset patch # User Augie Fackler # Date 2013-09-20 14:18:09 # Node ID 6fb1b7728719716753cedbd9ff431a75875b25c8 # Parent efee1f35fcae6a156b066890cb68ee362b50dd56 check-code: new rule to forbid imports of a.b on the same line as other imports This style of import can trip up 2to3 and cause it to produce invalid files if one of the imports is supposed to be a relative import. This prevents that behavior, and in the process exposed a lot of silly import errors related to the email module. diff --git a/contrib/check-code.py b/contrib/check-code.py --- a/contrib/check-code.py +++ b/contrib/check-code.py @@ -162,6 +162,9 @@ pypats = [ "tuple parameter unpacking not available in Python 3+"), (r'lambda\s*\(.*,.*\)', "tuple parameter unpacking not available in Python 3+"), + (r'import (.+,[^.]+\.[^.]+|[^.]+\.[^.]+,)', + '2to3 can\'t always rewrite "import qux, foo.bar", ' + 'use "import foo.bar" on its own line instead.'), (r'(?