Hello,
Here is a proposed fix for ticket #18860
diff -r f5f084e5267a ChangeLog
--- a/ChangeLog Thu Mar 04 12:12:32 2010 +0100
+++ b/ChangeLog Sun Mar 14 14:23:19 2010 -0400
@@ -1,7 +1,9 @@
ChangeLog for PyLint
====================
--
- * fix #9263, __init__ and __new__ are checked for unused arguments.
+ * fix #18860: warn on assert( a, b ?)
+
+ * fix #9263, __init__ and __new__ are checked for unused arguments.
* fix #20991, class scope definitions ignored in a genexpr
diff -r f5f084e5267a checkers/base.py
--- a/checkers/base.py Thu Mar 04 12:12:32 2010 +0100
+++ b/checkers/base.py Sun Mar 14 14:23:19 2010 -0400
@@ -165,7 +165,11 @@
finally clause of a try...finally block: the exceptions
raised \
in the try clause will be silently swallowed instead of
being \
re-raised."),
-
+ 'W0199': ('Assert was used on a tuple.',
+ 'A call of assert on a tuple will always evaluate to true
if '
+ 'the tuple is not empty, and will always evaluate to
false if '
+ 'it is.'),
+
'C0102': ('Black listed name "%s"',
'Used when the name is listed in the black list
(unauthorized \
names).'),
@@ -560,7 +564,12 @@
isinstance(node.operand, astng.UnaryOp) and
(node.operand.op == node.op)):
self.add_message('E0107', node=node, args=node.op*2)
-
+
+ def visit_assert(self, node):
+ """check the use of an assert statement on a tuple."""
+ if isinstance(node.test, astng.Tuple):
+ self.add_message('W0199', line=node.fromlineno, node=node)
+
def visit_dict(self, node):
"""check duplicate key in dictionary"""
keys = set()
Testing info is as follows:
test/input/func_w0199.py
'''Assert check example'''
__revision__ = 0
assert (1 == 1, 2 == 2), "Bad things"
assert (1 == 1, 2 == 2)
assert 1 == 1, "Bad things"
assert (1 == 1, ), "Bad things"
assert (1 == 1, )
assert (1 == 1, 2 == 2, 3 == 5), "Bad things"
assert ()
test/messages/func_w0199.txt
W: 4: Assert was used on a tuple.
W: 5: Assert was used on a tuple.
W: 7: Assert was used on a tuple.
W: 8: Assert was used on a tuple.
W: 9: Assert was used on a tuple.
W: 10: Assert was used on a tuple.
_______________________________________________
Python-Projects mailing list
[email protected]
http://lists.logilab.org/mailman/listinfo/python-projects