A method never uses self, so it does not need an instance

tx0/python:method-could-be-staticstrictnotesmell

What it finds

A method that never reads self does not depend on the object it is called on; as a function or staticmethod it says so, and can be called and tested without making an instance. Not reported are methods with decorators, special methods, methods whose body only raises, returns a constant or passes (which are often meant to be overridden), and methods of classes with bases, which may override a method that uses the instance.

From the rule's source, method_could_be_static.rs.

Example from the rule's tests
class Parser:    def parse(self, text):tx0 reports: parse never uses its instance        return text.split()     def size(self):        return self.n     def hook(self):        pass     def todo(self):        raise NotImplementedError     def __len__(self):        return 0     @property    def name(self):        return "p"  class Child(Base):    def parse(self, text):        return text
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 strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/python:method-could-be-static" = "note"

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-could-be-static] reason="..."

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