ruff/crates/ruff_linter/resources/test/fixtures/pylint/invalid_characters.py
InSync 7d2e40be2d
[pylint] Do not offer fix for raw strings (PLE251) (#16132)
## Summary

Resolves #13294, follow-up to #13882.

At #13882, it was concluded that a fix should not be offered for raw
strings. This change implements that. The five rules in question are now
no longer always fixable.

## Test Plan

`cargo nextest run` and `cargo insta test`.

---------

Co-authored-by: Micha Reiser <micha@reiser.io>
2025-02-13 08:36:11 +00:00

1.7 KiB
Raw Blame History

# ensures language of the file is detected as English in text editors
# (Pylint, "E1206") => Rule::LoggingTooFewArgs,
# (Pylint, "E1307") => Rule::BadStringFormatType,
# (Pylint, "E2502") => Rule::BidirectionalUnicode,
# (Pylint, "E2510") => Rule::InvalidCharacterBackspace,
# (Pylint, "E2511") => Rule::InvalidCharacterCarriageReturn,
# (Pylint, "E2512") => Rule::InvalidCharacterSub,
# (Pylint, "E2513") => Rule::InvalidCharacterEsc,
# (Pylint, "E2514") => Rule::InvalidCharacterNul,
# (Pylint, "E2515") => Rule::InvalidCharacterZeroWidthSpace,
# (Pylint, "E1310") => Rule::BadStrStripCall,
# (Pylint, "C0414") => Rule::UselessImportAlias,
# (Pylint, "C3002") => Rule::UnnecessaryDirectLambdaCall,
#foo = 'hi'
b = '
b = f'
 
b_ok = '\\b'
b_ok = f'\\b'
 
cr_ok = '\\r'
cr_ok = f'\\r'
 
sub = 'sub '
sub = f'sub '
 
sub_ok = '\x1a'
sub_ok = f'\x1a'
 
esc = 'esc esc '
esc = f'esc esc '
 
esc_ok = '\x1b'
esc_ok = f'\x1b'
 
nul = '''
nul '''
nul = f'''
nul '''
 
nul_ok = '\0'
nul_ok = f'\0'
 
zwsp = 'zerowidth'
zwsp = f'zerowidth'
 
zwsp_ok = '\u200b'
zwsp_ok = f'\u200b'
 
zwsp_after_multibyte_character = "ಫ​"
zwsp_after_multibyte_character = f"ಫ​"
zwsp_after_multicharacter_grapheme_cluster = "ಫ್ರಾನ್ಸಿಸ್ಕೊ "
zwsp_after_multicharacter_grapheme_cluster = f"ಫ್ರಾನ್ಸಿಸ್ಕೊ "
 
nested_fstrings = f{f'{f''}'}'
 
# https://github.com/astral-sh/ruff/issues/7455#issuecomment-1741998106
x = f"""}}ab"""
# https://github.com/astral-sh/ruff/issues/7455#issuecomment-1741998256
x = f"""}}ab"""
 
 
# https://github.com/astral-sh/ruff/issues/13294
print(r""
""")
print(fr""
""")
print(Rf""
""")