You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The rule you mentioned is similar to FURB111 as it detects lambdas where the arguments are passed verbatim, making the lambda redundant.
Adding detection for partial would be good, and there is already an issue open for it (see #173). I haven't had any concrete examples of code that Refurb should replace with partial though, so it's been hard to create a rule for it since I don't know what Refurb should be looking for. Having this code snippet helps.
In general, I think we can replace the following examples:
My only concern is that lambdas restrict the amount and types of arguments you can pass it, while partial will allow any extra args/kwargs, which might not be desirable. I think this would be good to add regardless, and people can decide to turn it off if they desire.
Overview
The following pattern I've seen being used for returning a new function based on another function with prefilled variables:
functools.partial
exactly does this, without needing the lambda to pass the input argument again.Somewhat related to this rule, although there we can remove the whole statement, and here only the input argument.
Proposal
Could this rule be included in refurb? There is already a
functools
section.The text was updated successfully, but these errors were encountered: