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
The fix for unnecessary-call-around-sorted (C413) in Ruff 0.9.3 can introduce a syntax error or change behavior when a newline appears between sorted and the opening parenthesis.
Syntax error:
$ cat >c413_1.py <<'# EOF'reversed(sorted(""))
# EOF
$ ruff --isolated check --select C413 c413_1.py --unsafe-fixes --fixerror: Fix introduced a syntax error. Reverting all changes.This indicates a bug in Ruff. If you could open an issue at: https://github.com/astral-sh/ruff/issues/new?title=%5BFix%20error%5D...quoting the contents of `c413_1.py`, the rule codes C413, along with the `pyproject.toml` settings and executed command, we'd be very appreciative!c413_1.py:1:1: C413 Unnecessary `reversed()` call around `sorted()` |1 | / reversed(sorted2 | | ("")) | |_____^ C413 | = help: Remove unnecessary `reversed()` callFound 1 error.[*] 1 fixable with the --fix option.
The text was updated successfully, but these errors were encountered:
dscorbett
changed the title
C413 fix is wrong when a newline appears between sorted opening parenthesis
C413 fix is wrong when a newline appears between sorted and the opening parenthesis
Jan 28, 2025
Thanks for this! This seems to keep cropping up... maybe worth adding a general edit for removing a function call so we don't have to rediscover this logic each time.
This seems to keep cropping up... maybe worth adding a general edit for removing a function call so we don't have to rediscover this logic each time.
Didn't end up doing this since the fix for this rule used codegen while the fix for the other rule I was thinking of used a text-based edit, so the logic was different.
Description
The fix for
unnecessary-call-around-sorted
(C413) in Ruff 0.9.3 can introduce a syntax error or change behavior when a newline appears betweensorted
and the opening parenthesis.Syntax error:
Changed behavior:
The text was updated successfully, but these errors were encountered: