A property accessor takes the wrong arguments, or its getter returns nothing

tx0/python:property-accessor-aritydefaultwarningbug

What it finds

@property def size(self, unit):: Python calls a property's getter with the instance alone, its setter with the instance and the value, and its deleter with the instance alone. An accessor that needs more, or cannot take that many, raises TypeError each time the attribute is read, set or deleted. A getter whose body never returns a value makes the attribute None every time, which is reported too, unless the body only raises or is a placeholder such as ... or pass.

From the rule's source, property_accessor_arity.rs.

Example from the rule's tests
class Box:    @property    def size(self, unit):tx0 reports: Python calls a property getter with the instance alone, which this one does not take        return unit     @size.setter    def size(self):tx0 reports: Python calls a property setter with the instance and the value        pass     @property    def label(self):tx0 reports: this property getter never returns a value, so the property is always None        self.text.strip()     @property    def area(self):        return 1     @property    def broken(self):        raise NotImplementedError     @property    def stub(self):        ...     @area.setter    def area(self, value):        self._area = value     @area.deleter    def area(self):        del self._area
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 in every tier. To turn it off for a project, set its level in tx0.toml:

tx0.toml
[rules]
"tx0/python:property-accessor-arity" = "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:property-accessor-arity] reason="..."

tx0 explain tx0/python:property-accessor-arity shows the same in the terminal. Found a false positive? Report it.