A method's decorators are stacked in an order that fails or no longer works
What it finds
Decorators applied in an order that does not work:
- @classmethod stacked on @property: class properties made this way were deprecated in Python 3.11 and stopped working in 3.13, where the attribute is a bound method instead of a value; - @abstractmethod above @property, @classmethod or @staticmethod: decorators apply from the bottom up, and abstractmethod cannot mark the object those return, so defining the class raises AttributeError. It belongs closest to the function.
From the rule's source, decorator_order.rs.
from abc import ABC, abstractmethod class Base(ABC): @classmethod @property def kind(cls):tx0 reports: @classmethod over @property no longer makes a class property since Python 3.13 return "base" @abstractmethod @property def size(self):tx0 reports: @abstractmethod above @property raises AttributeError; it belongs closest to the function return 0 @property @abstractmethod def area(self): return 0 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:decorator-order" = "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:decorator-order] reason="..."tx0 explain tx0/python:decorator-order shows the same in the terminal. Found a false positive? Report it.