PY-CLAS0008 · direct_method_descriptor_call_count
Count staticmethod and classmethod calls used without decorator syntax.
This is a deterministic rule for python. Read its implementation.
Definition
Section titled “Definition”Parse one Python source file and count direct calls to the built-in staticmethod or
classmethod descriptor constructors. This includes their explicit builtins forms. Method
binding policy should be visible next to the method declaration through @staticmethod or
@classmethod, not reconstructed through assignment or a class-body alias.
Evidence
Section titled “Evidence”Each finding identifies the complete call range and the descriptor constructor that was invoked. A bare decorator is an AST decorator name rather than a call, so normal decorator syntax cannot trigger this rule. The value is the number of direct descriptor constructor calls.
Exceptions
Section titled “Exceptions”Python permits direct descriptor construction, so this is an explicit readability policy rather than a language error. Calls through dynamic aliases are not guessed. Projects that intentionally build descriptors or metaclasses dynamically can disable this rule for that narrow source boundary.
Examples
Section titled “Examples”class Parser: parse = staticmethod(parse)
wrapped = classmethod(build)class Parser: @staticmethod def parse(text: str) -> "Parser": return Parser(text)
@classmethod def build(cls, text: str) -> "Parser": return cls(text)References
Section titled “References”- Cites “The Python Standard Library”, staticmethod. Open reference
- Cites “The Python Standard Library”, classmethod. Open reference
- Cites “Python HOWTOs”, descriptor guide. Open reference