Skip to content

ALL-FUNC0005 · transparent_unary_wrapper

Detect a public unary function that only forwards one argument.

This is a deterministic rule for all languages. Read its implementation.

Report a synchronous public module function or static method only when it has one required parameter and its sole executable statement returns one call with that parameter unchanged. A direct callable alias or direct call expresses the same dispatch without another boundary.

Each finding identifies the wrapper, forwarded callable, and complete source range. The rule does not infer semantic similarity or inspect nested behavior.

Instance methods, class methods, private helpers, asynchronous adapters, decorators other than staticmethod, overloads, defaults, argument adaptation, result transformation, and recursive calls are excluded. A narrowing annotation alone does not preserve a wrapper when the called function already exposes the same narrowing contract. Keep a wrapper when its distinct __name__, signature, documentation, instrumentation, or compatibility boundary is an intentional public contract.

Bad

`def normalize(value: str) -> str: return inflection.underscore(value)` adds only a forwarding
frame.
Good

normalize = inflection.underscore gives the callable a project name directly. A function that validates, transforms, logs, awaits, or combines arguments remains a real boundary. Inside a method, call inspect.isclass(value) directly instead of wrapping it as is_class.

  • Cites “The Python Language Reference”, assignment statements. Open reference
  • Cites “A Philosophy of Software Design”, chapters 4 and 7
  • Cites “Clean Code”, chapter 3