comparison contrib/check-code.py @ 20688:a61ed1c2d7a7

check-code: disallow use of dict(key=value) construction {} literals are faster and more consistent across Python 2 and 3. Whitelisted the one use of dict() that is using a generator expresion.
author Augie Fackler <raf@durin42.com>
date Wed, 12 Mar 2014 13:31:27 -0400
parents e57e2da803aa
children 131f7fe06e9e
comparison
equal deleted inserted replaced
20687:7d4d04299927 20688:a61ed1c2d7a7
198 (r'import (.+,[^.]+\.[^.]+|[^.]+\.[^.]+,)', 198 (r'import (.+,[^.]+\.[^.]+|[^.]+\.[^.]+,)',
199 '2to3 can\'t always rewrite "import qux, foo.bar", ' 199 '2to3 can\'t always rewrite "import qux, foo.bar", '
200 'use "import foo.bar" on its own line instead.'), 200 'use "import foo.bar" on its own line instead.'),
201 (r'(?<!def)\s+(cmp)\(', "cmp is not available in Python 3+"), 201 (r'(?<!def)\s+(cmp)\(', "cmp is not available in Python 3+"),
202 (r'\breduce\s*\(.*', "reduce is not available in Python 3+"), 202 (r'\breduce\s*\(.*', "reduce is not available in Python 3+"),
203 (r'dict\(.*=', 'dict() is different in Py2 and 3 and is slower than {}',
204 'dict-from-generator'),
203 (r'\.has_key\b', "dict.has_key is not available in Python 3+"), 205 (r'\.has_key\b', "dict.has_key is not available in Python 3+"),
204 (r'\s<>\s', '<> operator is not available in Python 3+, use !='), 206 (r'\s<>\s', '<> operator is not available in Python 3+, use !='),
205 (r'^\s*\t', "don't use tabs"), 207 (r'^\s*\t', "don't use tabs"),
206 (r'\S;\s*\n', "semicolon"), 208 (r'\S;\s*\n', "semicolon"),
207 (r'[^_]_\("[^"]+"\s*%', "don't use % inside _()"), 209 (r'[^_]_\("[^"]+"\s*%', "don't use % inside _()"),