NoRedundantLambdaRule
- A lamba function which has a single objective of
passing all it is arguments to another callable can be safely replaced by that callable.
Has Autofix: Yes
VALID Code Examples
# 1:
lambda x: foo(y)
# 2:
lambda x: foo(x, y)
# 3:
lambda x, y: foo(x)
# 4:
lambda *, x: foo(x)
# 5:
lambda x = y: foo(x)
# 6:
lambda x, y: foo(y, x)
# 7:
lambda self: self.func()
# 8:
lambda x, y: foo(y=x, x=y)
# 9:
lambda x, y, *z: foo(x, y, z)
# 10:
lambda x, y, **z: foo(x, y, z)
INVALID Code Examples
# 1:
lambda: self.func()
Autofix:
---
+++
@@ -1 +1 @@
-lambda: self.func()
+self.func
# 2:
lambda x: foo(x)
Autofix:
---
+++
@@ -1 +1 @@
-lambda x: foo(x)
+foo
# 3:
lambda x, y, z: (t + u).math_call(x, y, z)
Autofix:
---
+++
@@ -1 +1 @@
-lambda x, y, z: (t + u).math_call(x, y, z)
+(t + u).math_call