A function calls itself before any condition can stop it, so every call recurses until the stack overflows
What it finds
A call of the function to itself among the plain statements that open its body, with no if, loop, try, return or raise before it, repeats on every call and ends in RecursionError. Property getters that read their own property recurse the same way. Calls inside conditional expressions, and/or, lambdas and comprehensions may not run and are left alone.
From the rule's source, unconditional_recursion.rs.
def forever(n): return forever(n - 1)tx0 reports: this call recurses every time def fine(n): if n == 0: return 0 return fine(n - 1) class Box: @property def size(self): return self.sizetx0 reports: this call recurses every time def area(self): total = self.area()tx0 reports: this call recurses every time return total def pick(self, a): return a and self.pick(a - 1) Turn it on, off or suppress it
The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:
[rules]
"tx0/python:unconditional-recursion" = "off"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
# tx0: ignore[tx0/python:unconditional-recursion] reason="..."tx0 explain tx0/python:unconditional-recursion shows the same in the terminal. Found a false positive? Report it.