python/multi-line-call-argument
| Pack | Severity | Fix | Versions |
|---|---|---|---|
| Python | warning | unsafe, with xpd check --fix --unsafe-fixes |
All versions |
A call that runs over several lines inside another call's arguments is hard to read. Give its result a name on the line above, and pass the name.
frames.append( pd.DataFrame( { "side": side, "cost": cost, "value": implied(kind, spread - d, markup), } ))value = implied(kind, spread - d, markup)frame = pd.DataFrame({"side": side, "cost": cost, "value": value})frames.append(frame)What the rule reports
Section titled “What the rule reports”The rule reports a call that runs over several lines and is an argument of another call.
How to fix it
Section titled “How to fix it”xpd has no automatic fix, so make the change by hand.
Two argument lists are nested, so a reader has to match the brackets to see which argument belongs to which call, and every line sits two or three levels deep. A name on the line above says what the inner call builds, and the outer call then fits on one line.
Diagnostic message
Section titled “Diagnostic message”This call runs over several lines inside the arguments of another call. Give its result a name on the line above, and pass the name.See all rules in the Python pack.