Mercurial > public > mercurial-scm > hg
comparison contrib/check-code.py @ 32418:1651977596c0
check-code: allow skipping hasattr check in py3-only code
hasattr is safe in Python 3, and in an upcoming patch we can't use
util.safehasattr.
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Sun, 21 May 2017 13:34:42 -0700 |
parents | ca727147ff9f |
children | 071423d0a584 |
comparison
equal
deleted
inserted
replaced
32417:f40dc6f7c12f | 32418:1651977596c0 |
---|---|
298 (r' [=!]=\s+(True|False|None)', | 298 (r' [=!]=\s+(True|False|None)', |
299 "comparison with singleton, use 'is' or 'is not' instead"), | 299 "comparison with singleton, use 'is' or 'is not' instead"), |
300 (r'^\s*(while|if) [01]:', | 300 (r'^\s*(while|if) [01]:', |
301 "use True/False for constant Boolean expression"), | 301 "use True/False for constant Boolean expression"), |
302 (r'(?:(?<!def)\s+|\()hasattr\(', | 302 (r'(?:(?<!def)\s+|\()hasattr\(', |
303 'hasattr(foo, bar) is broken, use util.safehasattr(foo, bar) instead'), | 303 'hasattr(foo, bar) is broken on py2, use util.safehasattr(foo, bar) ' |
304 'instead', r'#.*hasattr-py3-only'), | |
304 (r'opener\([^)]*\).read\(', | 305 (r'opener\([^)]*\).read\(', |
305 "use opener.read() instead"), | 306 "use opener.read() instead"), |
306 (r'opener\([^)]*\).write\(', | 307 (r'opener\([^)]*\).write\(', |
307 "use opener.write() instead"), | 308 "use opener.write() instead"), |
308 (r'[\s\(](open|file)\([^)]*\)\.read\(', | 309 (r'[\s\(](open|file)\([^)]*\)\.read\(', |