Comments
Patch
@@ -318,7 +318,7 @@
(r'ui\.(status|progress|write|note|warn)\([\'\"]x',
"missing _() in ui message (use () to hide false-positives)"),
(r'release\(.*wlock, .*lock\)', "wrong lock release order"),
- (r'\b__bool__\b', "__bool__ should be __nonzero__ in Python 2"),
+ (r'\bdef __bool__\b|\b__bool__\(', "__bool__ should be __nonzero__ in Python 2"),
(r'os\.path\.join\(.*, *(""|\'\')\)',
"use pathutil.normasprefix(path) instead of os.path.join(path, '')"),
(r'\s0[0-7]+\b', 'legacy octal syntax; use "0o" prefix instead of "0"'),
@@ -36,12 +36,19 @@
return d.iteritems()
def itervalues(d):
return d.itervalues()
+ def boolclass(cls):
+ """class decorator for classes with __bool__ method"""
+ return cls
except AttributeError:
# Python 3
def iteritems(d):
return iter(d.items())
def itervalues(d):
return iter(d.values())
+ def boolclass(cls):
+ """class decorator for classes with __bool__ method"""
+ cls.__bool__ = cls.__nonzero__
+ return cls
try:
import cStringIO as io
@@ -46,6 +46,7 @@
)
for attr in (
+ 'boolclass',
'email',
'empty',
'http',