ruff
ruff copied to clipboard
Convert raw strings to non-raw when fixes add escape sequences (#13294)
Summary
This aims to resolve #13294 by implementing raw to non-raw string conversion, as suggested by @dscorbett. The conversion is comprehensive (as far as I'm aware), but it does introduce an unfortunate amount of complexity to the rule.
I'm new to this codebase and not a Rust expert, so my code might not be idiomatic.
Test Plan
I have added the following test cases:
raw_single_singlequote = r'\ \' " '
raw_triple_singlequote = r'''\ ' " '''
raw_single_doublequote = r"\ ' \" "
raw_triple_doublequote = r"""\ ' " """
raw_single_singlequote_multiline = r'\' \
" \
'
raw_triple_singlequote_multiline = r'''' \
" \
'''
raw_single_doublequote_multiline = r"' \
\" \
"
raw_triple_doublequote_multiline = r"""' \
" \
"""
raw_nested_fstrings = rf'\ {rf'\ {rf'\' '}'}'