
On Thu, Nov 25, 2021 at 9:51 AM Barry <barry@barrys-emacs.org> wrote:
One common error that I haven't seen discussed is bare logical comparisons. They're syntactically legal so they don't raise errors, but I have never seen a real-world use case for one.
nor have I. However, this strikes me as very much a problem for linters to solve (and some do already). I just tried mine, and it doesn't.
name == 'ever'
I do get a undefined name error in the linter if I do this by itself, but, of course not if name haad been previously defined. However, even from a linter's perspective, I think this is not exactly misuse of "==", b ut rather a amore general "expression not assigned to anything" working. Of course, as Barry pointed out, you might have an unassigned expression in order to get a side effect. But the reason I think it's a linter's job is that I don't think there is any other case where Python tries to warn you about things that are not illegal. Yes, this is one example where it might make sense, but where do we draw the line? -CHB -- Christopher Barker, PhD (Chris) Python Language Consulting - Teaching - Scientific Software Development - Desktop GUI and Web Development - wxPython, numpy, scipy, Cython