mirror of
https://github.com/astral-sh/ruff
synced 2026-01-22 05:51:03 -05:00
## Summary This PR stabilizes the behavior change introduced in https://github.com/astral-sh/ruff/pull/15872/ The diagnostic range is now the range of the redundant `mode` argument where it previously was the range of the entire `open` call: Before: ``` UP015.py:2:1: UP015 [*] Unnecessary mode argument | 1 | open("foo", "U") 2 | open("foo", "Ur") | ^^^^^^^^^^^^^^^^^ UP015 3 | open("foo", "Ub") 4 | open("foo", "rUb") | = help: Remove mode argument ``` Now: ``` UP015.py:2:13: UP015 [*] Unnecessary mode argument | 1 | open("foo", "U") 2 | open("foo", "Ur") | ^^^^ UP015 3 | open("foo", "Ub") 4 | open("foo", "rUb") | = help: Remove mode argument ``` This is a breaking change because it may require moving a `noqa` comment onto a different line, e.g if you have ```py open( "foo", "Ur", ) # noqa: UP015 ``` Needs to be rewritten to ```py open( "foo", "Ur", # noqa: UP015 ) ``` There have been now new issues or PRs since the new preview behavior was implemented. It first was released as part of Ruff 0.9.5 on the 5th of Feb (a little more than a month ago) ## Test Plan I reviewed the snapshot tests