Skip to content

Commit ca6a20d

Browse files
authored
Stabilize PLW0108 (#22927)
I tried to simplify the docs slightly by using a code block instead of a fairly long inline function definition, but the docs and tests otherwise looked good to me. https://docs.astral.sh/ruff/rules/unnecessary-lambda/
1 parent 882babf commit ca6a20d

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

‎crates/ruff_linter/src/rules/pylint/rules/unnecessary_lambda.rs‎

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,22 @@ use crate::{Edit, Fix, FixAvailability, Violation};
3838
/// change the argument names, which can lead to a change in behavior when
3939
/// callers pass arguments by name.
4040
///
41-
/// For example, replacing `foo = lambda x, y: func(x, y)` with `foo = func`,
42-
/// where `func` is defined as `def func(a, b): return a + b`, would be a
43-
/// breaking change for callers that execute the lambda by passing arguments by
44-
/// name, as in: `foo(x=1, y=2)`. Since `func` does not define the arguments
45-
/// `x` and `y`, unlike the lambda, the call would raise a `TypeError`.
41+
/// For example:
42+
///
43+
/// ```python
44+
/// def func(a, b):
45+
/// return a + b
46+
///
47+
///
48+
/// foo = lambda x, y: func(x, y)
49+
/// ```
50+
///
51+
/// Replacing the assignment to `foo` with `foo = func` would be a breaking
52+
/// change for callers that execute the lambda by passing arguments by name, as
53+
/// in: `foo(x=1, y=2)`. Since `func` does not define the arguments `x` and `y`,
54+
/// unlike the lambda, the call would raise a `TypeError`.
4655
#[derive(ViolationMetadata)]
47-
#[violation_metadata(preview_since = "v0.1.2")]
56+
#[violation_metadata(stable_since = "0.15.0")]
4857
pub(crate) struct UnnecessaryLambda;
4958

5059
impl Violation for UnnecessaryLambda {

0 commit comments

Comments
 (0)