> if you get a Tuple instance as assert expression without infering, that's
> a literal.

Thanks, I wasn't aware of this. I'm not yet very familiar with the ASTNG module.

> Please don't warn on literal False, since I use that quite often in
> situations like this:
>
>        if a.hasSomeProperty():
>                doSomething()
>        elif a.hasSomeOtherProperty():
>                doSomethingElse()
>        else:
>                assert False, 'a is in an invalid state'

Wouldn't "raise AssertionError('a is in an invalid state')" be more
clear? Or "raise ValueError('a is an invalid state')"? Or, if you
wanted to use an assert, why not put it before the if block and do
"assert a.hasSomeProperty() or a.hasSomeOtherProperty(), 'a is an
invalid state'"? I'm not a Python guru, but those seem more idiomatic
to me. Still, I agree that asserting a tautology seems somehow 'worse'
than asserting a contradiction, since the latter actually has some
effect.

--
Colin Morris
Team Tahiti
University of Toronto

On Thu, Mar 18, 2010 at 6:38 AM, Maarten ter Huurne
<maar...@treewalker.org> wrote:
>
> On Thursday 18 March 2010, Sylvain Thénault wrote:
>
> > IMO we should:
> > * *not infer anything here*
> > * check for 2-uple and warn about potential misspelling of the assert
> > statement * check for literal true (eg True, not empty container, non
> > zero number, etc..) of false (False, None, 0, etc...) expression and
> > warn about always/never verified assertion
>
> Please don't warn on literal False, since I use that quite often in
> situations like this:
>
>        if a.hasSomeProperty():
>                doSomething()
>        elif a.hasSomeOtherProperty():
>                doSomethingElse()
>        else:
>                assert False, 'a is in an invalid state'
>
> Bye,
>                Maarten
> _______________________________________________
> Python-Projects mailing list
> Python-Projects@lists.logilab.org
> http://lists.logilab.org/mailman/listinfo/python-projects
_______________________________________________
Python-Projects mailing list
Python-Projects@lists.logilab.org
http://lists.logilab.org/mailman/listinfo/python-projects

Reply via email to