Is there a tool which will catch this sort of mistake?
I stumbled on this in a colleague's code today: class MyClass(object): def __init__(self, me): self._name = me @property def name(self): return self.name Running this code would find the bug very quickly (good argument for unit tests). Still, it would be nice if some static analysis tool could identify that the return value would produce infinite recursion. Neither pylint nor pyflakes complained. I'm not asking for a solution to the halting problem. Just a realization that you are inside a property method and returning that item. I'd be happy for a false positive or two. I'm well-steeped in use of # pylint: disable=... One more in rare cases wouldn't be a big deal. (I'd be happy to try and write a checker for pylint. Last time I looked though a few years ago, I lacked enough knowledge of the code base to knock something out.) Skip Montanaro
participants (1)
-
Skip Montanaro