##// END OF EJS Templates
check-code: disallow use of dict(key=value) construction...
Augie Fackler -
r20688:a61ed1c2 default
parent child Browse files
Show More
@@ -200,6 +200,8 b' pypats = ['
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"),
@@ -30,7 +30,8 b' class remotestore(basestore.basestore):'
30 % (source, util.hidepassword(self.url)))
30 % (source, util.hidepassword(self.url)))
31
31
32 def exists(self, hashes):
32 def exists(self, hashes):
33 return dict((h, s == 0) for (h, s) in self._stat(hashes).iteritems())
33 return dict((h, s == 0) for (h, s) in # dict-from-generator
34 self._stat(hashes).iteritems())
34
35
35 def sendfile(self, filename, hash):
36 def sendfile(self, filename, hash):
36 self.ui.debug('remotestore: sendfile(%s, %s)\n' % (filename, hash))
37 self.ui.debug('remotestore: sendfile(%s, %s)\n' % (filename, hash))
@@ -97,4 +98,3 b' class remotestore(basestore.basestore):'
97 def batch(self):
98 def batch(self):
98 '''Support for remote batching.'''
99 '''Support for remote batching.'''
99 return remotebatch(self)
100 return remotebatch(self)
100
@@ -123,6 +123,7 b''
123 $ cat > python3-compat.py << EOF
123 $ cat > python3-compat.py << EOF
124 > foo <> bar
124 > foo <> bar
125 > reduce(lambda a, b: a + b, [1, 2, 3, 4])
125 > reduce(lambda a, b: a + b, [1, 2, 3, 4])
126 > dict(key=value)
126 > EOF
127 > EOF
127 $ "$check_code" python3-compat.py
128 $ "$check_code" python3-compat.py
128 python3-compat.py:1:
129 python3-compat.py:1:
@@ -131,6 +132,9 b''
131 python3-compat.py:2:
132 python3-compat.py:2:
132 > reduce(lambda a, b: a + b, [1, 2, 3, 4])
133 > reduce(lambda a, b: a + b, [1, 2, 3, 4])
133 reduce is not available in Python 3+
134 reduce is not available in Python 3+
135 python3-compat.py:3:
136 > dict(key=value)
137 dict() is different in Py2 and 3 and is slower than {}
134 [1]
138 [1]
135
139
136 $ cat > is-op.py <<EOF
140 $ cat > is-op.py <<EOF
General Comments 0
You need to be logged in to leave comments. Login now