ruff/crates/ruff_linter/resources
Gene Parmesan Thomas 5b3a501fae
[pylint] Avoid flattening nested min/max when outer call has single argument (PLW3301) (#16885)
## Summary

Fixes false positives (and incorrect autofixes) in `nested-min-max`
(`PLW3301`) when the outer `min`/`max` call only has a single argument.
Previously the rule would flatten:

```python
min(min([2, 3], [4, 1]))
```

into `min([2, 3], [4, 1])`, changing the semantics. The rule now skips
any nested call when the outer call has only one positional argument.
The pylint fixture and snapshot were updated accordingly.

## Test Plan

Ran Ruff against the updated `nested_min_max.py` fixture:

```shell
cargo run -p ruff -- check crates/ruff_linter/resources/test/fixtures/pylint/nested_min_max.py --no-cache --select=PLW3301 --preview
```

to verify that `min(min([2, 3], [4, 1]))` and `max(max([2, 4], [3, 1]))`
are no longer flagged. Updated the fixture and snapshot; all other
existing warnings remain unchanged. The code compiles and the unit tests
pass.

---

This PR was generated by an AI system in collaboration with maintainers:
@carljm, @ntBre

Fixes #16163

---------

Signed-off-by: Gene Parmesan Thomas <201852096+gopoto@users.noreply.github.com>
Co-authored-by: Brent Westbrook <brentrwestbrook@gmail.com>
2025-06-20 09:35:09 -04:00
..
test [pylint] Avoid flattening nested min/max when outer call has single argument (PLW3301) (#16885) 2025-06-20 09:35:09 -04:00
__init__.py [pylint] (Re-)Implement import-private-name (C2701) (#9553) 2024-01-16 14:03:11 -05:00