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
lambda obj: obj.name() is equivalent to operator.methodcaller('name')
This may be equivalent, but it is certainly worse. It requires more code, it requires importing another module, and its intent is simply not as clear to inexperienced programmers.
Since you have "
lambda: []
is equivalent to the builtinlist
", I suggest other rules with similar refactoring strategies:lambda: {}
is equivalent to the builtindict
lambda arg: f(arg)
is equivalent tof
lambda obj: obj.attr
is equivalent tooperator.attrgetter('attr')
lambda items: items[0]
is equivalent tooperator.itemgetter(0)
lambda obj: obj.name()
is equivalent tooperator.methodcaller('name')
The descriptions are still not generic enough, and maybe should not be the ones to be really used.
Some of these rules can be rather complex, in terms of all the possible variations.
The text was updated successfully, but these errors were encountered: