comparison contrib/check-code.py @ 19793:6fb1b7728719

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.
author Augie Fackler <raf@durin42.com>
date Fri, 20 Sep 2013 10:18:09 -0400
parents 22a70f31e3e9
children 681f7b9213a4
comparison
equal deleted inserted replaced
19792:efee1f35fcae 19793:6fb1b7728719
160 [ 160 [
161 (r'^\s*def\s*\w+\s*\(.*,\s*\(', 161 (r'^\s*def\s*\w+\s*\(.*,\s*\(',
162 "tuple parameter unpacking not available in Python 3+"), 162 "tuple parameter unpacking not available in Python 3+"),
163 (r'lambda\s*\(.*,.*\)', 163 (r'lambda\s*\(.*,.*\)',
164 "tuple parameter unpacking not available in Python 3+"), 164 "tuple parameter unpacking not available in Python 3+"),
165 (r'import (.+,[^.]+\.[^.]+|[^.]+\.[^.]+,)',
166 '2to3 can\'t always rewrite "import qux, foo.bar", '
167 'use "import foo.bar" on its own line instead.'),
165 (r'(?<!def)\s+(cmp)\(', "cmp is not available in Python 3+"), 168 (r'(?<!def)\s+(cmp)\(', "cmp is not available in Python 3+"),
166 (r'\breduce\s*\(.*', "reduce is not available in Python 3+"), 169 (r'\breduce\s*\(.*', "reduce is not available in Python 3+"),
167 (r'\.has_key\b', "dict.has_key is not available in Python 3+"), 170 (r'\.has_key\b', "dict.has_key is not available in Python 3+"),
168 (r'\s<>\s', '<> operator is not available in Python 3+, use !='), 171 (r'\s<>\s', '<> operator is not available in Python 3+, use !='),
169 (r'^\s*\t', "don't use tabs"), 172 (r'^\s*\t', "don't use tabs"),