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
This issue was mentioned in #14679 (comment) with the example of \g<0>, which was deemed acceptably implausible. Because a replacement string can also include character escapes, this issue is plausible.
Alternatively, this could be considered a true positive, in which case the fix needs to interpret escape sequences in the replacement string.
The text was updated successfully, but these errors were encountered:
Okay, so the part that we overlooked from the specification is:
if it is a string, any backslash escapes in it are processed. That is, \n is converted to a single newline character, \r is converted to a carriage return, and so forth.
Thanks @dscorbett, as ever! You were quite right that #14679 would not have fixed this in its earlier form. I pushed some updates to it, so I think it now handles everything correctly, though. Let us know if you see any other issues with the check!
In Ruff 0.8.1,
unnecessary-regular-expression
(RUF055) reports a false positive forre.sub
when the replacement string contains a backslash.This issue was mentioned in #14679 (comment) with the example of
\g<0>
, which was deemed acceptably implausible. Because a replacement string can also include character escapes, this issue is plausible.Alternatively, this could be considered a true positive, in which case the fix needs to interpret escape sequences in the replacement string.
The text was updated successfully, but these errors were encountered: