On Mon, Nov 17, 2014 at 05:18:03PM +0000, Stefan Bucur wrote: > I wanted first to tap into people's experience and get a sense of what > common pitfalls in the language & its standard library such a static > checker should look for. [...] > * Proper Unicode handling (for 2.x) > - encode() is not called on str object > - decode() is not called on unicode object > * Check for integer division by zero > * Check for None object dereferences
This is a very interesting question, and quite hard to answer too. I presume that there will be a way to disable the check for individual lines of code, because these are not always wrong. * Check for `is` comparisons against arbitrary objects, especially int and str literals. * Equality comparisons against None (should use `is`). * Calling str.find() and str.rfind() without checking for a return result of -1. * Calling re.match() and similar without checking for a result of None. * alist = alist.sort() and similar. * Calling print for its return value, e.g.: print("template %s") % obj * Mutable default values in functions and methods. * Modifying a sequence or iterator while iterating over it, e.g. for i, x in enumerate(alist): if condition(x): del alist[i] I've done all of these :-( -- Steven _______________________________________________ code-quality mailing list code-quality@python.org https://mail.python.org/mailman/listinfo/code-quality