If it were possible to check a little more carefully what's being asserted,
then we could give a very specific message. As I understand it, we're
warning against the case where someone is trying to assert some boolean
expression along with a message to pass to the AssertionError's constructor
("assert x, msg"), but instead muddles the syntax and asserts a tuple
("assert (x, msg)"). If we could check that what's being asserted is a size
2 tuple literal, then we could give a more specific message like: "Assertion
will always be true. Did you mean 'assert x, msg'?". Also, that could avoid
some false positives since, I imagine, there are legitimate situations where
you might want to assert some variable that holds a tuple of undetermined
size (though 'assert len(sometuple) is not 0' might be more clear). I don't
know if this is possible though--can the ASTNG tell whether a tuple is a
literal or not?Without those checks, we can't really be sure that the assertion will always be true, so the warning message would have to be a bit more noncommittal. Maybe something like: "Found assertion of tuple. Did you mean to do 'assert a, msg'?" or "Assertion of a non-empty tuple will always pass. Did you mean 'assert a, msg'?" -- Colin Morris Team Tahiti University of Toronto On Mon, Mar 15, 2010 at 7:02 AM, Sylvain Thénault < [email protected]> wrote: > On 14 mars 14:36, Fletcher Johnson wrote: > > Hello, > > Hi, > > > Here is a proposed fix for ticket #18860 > > sounds good to me. The only thing I'm not keen on is the message. > Maybe people here have some suggestions to improve it? > > -- > Sylvain Thénault LOGILAB, Paris (France) > Formations Python, Debian, Méth. Agiles: http://www.logilab.fr/formations > Développement logiciel sur mesure: http://www.logilab.fr/services > CubicWeb, the semantic web framework: http://www.cubicweb.org > > _______________________________________________ > Python-Projects mailing list > [email protected] > http://lists.logilab.org/mailman/listinfo/python-projects >
_______________________________________________ Python-Projects mailing list [email protected] http://lists.logilab.org/mailman/listinfo/python-projects
