diff 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
line wrap: on
line diff
--- a/contrib/check-code.py	Wed Mar 12 13:29:29 2014 -0400
+++ b/contrib/check-code.py	Wed Mar 12 13:31:27 2014 -0400
@@ -200,6 +200,8 @@
      'use "import foo.bar" on its own line instead.'),
     (r'(?<!def)\s+(cmp)\(', "cmp is not available in Python 3+"),
     (r'\breduce\s*\(.*', "reduce is not available in Python 3+"),
+    (r'dict\(.*=', 'dict() is different in Py2 and 3 and is slower than {}',
+     'dict-from-generator'),
     (r'\.has_key\b', "dict.has_key is not available in Python 3+"),
     (r'\s<>\s', '<> operator is not available in Python 3+, use !='),
     (r'^\s*\t', "don't use tabs"),