sklego/log-step-extra-bare
| Pack | Severity | Fix | Versions |
|---|---|---|---|
| scikit-lego | error | unsafe, with xpd check --fix --unsafe-fixes |
All versions |
A bare @log_step_extra takes the decorated function as a log function, so calling the function returns another function and not a frame. Pass the log functions, as in @log_step_extra(len).
@log_step_extra@log_step_extra(len)def add_total(frame): return frame.assign(total=frame["price"] * frame["count"])What the rule reports
Section titled “What the rule reports”The rule reports @log_step_extra without arguments, as a bare decorator or with empty
parentheses. log_step works both ways, but log_step_extra takes the log functions as its
arguments. As a bare decorator it takes the decorated function as a log function.
How to fix it
Section titled “How to fix it”With --unsafe-fixes, xpd replaces an empty call with log_step.
| Form | Result |
|---|---|
@log_step_extra |
Calling the function returned another function, not a frame, and raised nothing. |
@log_step_extra() |
ValueError "Supply at least one log_function for log_step_extra" |
Diagnostic message
Section titled “Diagnostic message”A bare @log_step_extra takes the decorated function as a log function, so calling the function returned another function, not a frame. Pass the log functions, as in @log_step_extra(len).See all rules in the scikit-lego pack.