A method has no parameter to receive the instance or class

tx0/python:method-without-selfrecommendedwarningbug

What it finds

def reset(): in a class body: calling a method through an instance passes the instance as the first argument, and through the class in a classmethod the class. A method without any parameter that can take it raises TypeError on every such call. @staticmethod is what makes a function in a class take no instance.

Methods with any decorator are left alone, since a decorator can change how the function is called. The rule is in the recommended tier because a class can also be used as a namespace whose functions are only ever called through the class.

From the rule's source, method_without_self.rs.

Example from the rule's tests
class Counter:    def reset():tx0 reports: the method reset has no parameter for the instance, so calling it raises TypeError        return 0     def keyed(*, key):tx0 reports: the method keyed has no parameter        return key     @staticmethod    def make():        return Counter()     def flexible(*args):        return args     def normal(self):        return self  def helper():    return 1
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/python:method-without-self" = "warning"

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:method-without-self] reason="..."

tx0 explain tx0/python:method-without-self shows the same in the terminal. Found a false positive? Report it.