crates/ruff_linter/resources/mdtest/pylint/invalid-character-backspace.md
invalid-character-backspace (PLE2510)target-version = "py39"
[lint]
select = ["PLE2510"]
Fixes are suppressed when replacing the backspace would introduce an escape sequence into an f-string replacement field. A nested f-string's literal text is still part of an outer replacement field.
replacement_field = f"{''}" # snapshot: invalid-character-backspace
nested_f_string = f"{f'hello'}" # snapshot: invalid-character-backspace
error[PLE2510]: Invalid unescaped character backspace, use "\b" instead
--> src/mdtest_snippet.py:1:25
|
1 | replacement_field = f"{'␈'}" # snapshot: invalid-character-backspace
| ^
|
help: Replace with escape sequence
error[PLE2510]: Invalid unescaped character backspace, use "\b" instead
--> src/mdtest_snippet.py:2:29
|
2 | nested_f_string = f"{f'hello␈'}" # snapshot: invalid-character-backspace
| ^
|
help: Replace with escape sequence
However, escapes are valid in format specs and literal f-string text:
format_spec = f"{value:}" # snapshot: invalid-character-backspace
f_string_literal = f"hello" # snapshot: invalid-character-backspace
error[PLE2510]: Invalid unescaped character backspace, use "\b" instead
--> src/mdtest_snippet.py:1:24
|
1 | format_spec = f"{value:␈}" # snapshot: invalid-character-backspace
| ^
|
help: Replace with escape sequence
- format_spec = f"{value:␈}" # snapshot: invalid-character-backspace
1 + format_spec = f"{value:\b}" # snapshot: invalid-character-backspace
2 | f_string_literal = f"hello␈" # snapshot: invalid-character-backspace
error[PLE2510]: Invalid unescaped character backspace, use "\b" instead
--> src/mdtest_snippet.py:2:27
|
2 | f_string_literal = f"hello␈" # snapshot: invalid-character-backspace
| ^
|
help: Replace with escape sequence
1 | format_spec = f"{value:␈}" # snapshot: invalid-character-backspace
- f_string_literal = f"hello␈" # snapshot: invalid-character-backspace
2 + f_string_literal = f"hello\b" # snapshot: invalid-character-backspace
target-version = "py312"
[lint]
select = ["PLE2510"]
PEP 701 permits escape sequences in replacement fields, so all of these fixes are available.
replacement_field = f"{''}" # snapshot: invalid-character-backspace
format_spec = f"{value:}" # snapshot: invalid-character-backspace
f_string_literal = f"hello" # snapshot: invalid-character-backspace
nested_f_string = f"{f'hello'}" # snapshot: invalid-character-backspace
error[PLE2510]: Invalid unescaped character backspace, use "\b" instead
--> src/mdtest_snippet.py:1:25
|
1 | replacement_field = f"{'␈'}" # snapshot: invalid-character-backspace
| ^
|
help: Replace with escape sequence
- replacement_field = f"{'␈'}" # snapshot: invalid-character-backspace
1 + replacement_field = f"{'\b'}" # snapshot: invalid-character-backspace
2 | format_spec = f"{value:␈}" # snapshot: invalid-character-backspace
3 | f_string_literal = f"hello␈" # snapshot: invalid-character-backspace
4 | nested_f_string = f"{f'hello␈'}" # snapshot: invalid-character-backspace
error[PLE2510]: Invalid unescaped character backspace, use "\b" instead
--> src/mdtest_snippet.py:2:24
|
2 | format_spec = f"{value:␈}" # snapshot: invalid-character-backspace
| ^
|
help: Replace with escape sequence
1 | replacement_field = f"{'␈'}" # snapshot: invalid-character-backspace
- format_spec = f"{value:␈}" # snapshot: invalid-character-backspace
2 + format_spec = f"{value:\b}" # snapshot: invalid-character-backspace
3 | f_string_literal = f"hello␈" # snapshot: invalid-character-backspace
4 | nested_f_string = f"{f'hello␈'}" # snapshot: invalid-character-backspace
error[PLE2510]: Invalid unescaped character backspace, use "\b" instead
--> src/mdtest_snippet.py:3:27
|
3 | f_string_literal = f"hello␈" # snapshot: invalid-character-backspace
| ^
|
help: Replace with escape sequence
1 | replacement_field = f"{'␈'}" # snapshot: invalid-character-backspace
2 | format_spec = f"{value:␈}" # snapshot: invalid-character-backspace
- f_string_literal = f"hello␈" # snapshot: invalid-character-backspace
3 + f_string_literal = f"hello\b" # snapshot: invalid-character-backspace
4 | nested_f_string = f"{f'hello␈'}" # snapshot: invalid-character-backspace
error[PLE2510]: Invalid unescaped character backspace, use "\b" instead
--> src/mdtest_snippet.py:4:29
|
4 | nested_f_string = f"{f'hello␈'}" # snapshot: invalid-character-backspace
| ^
|
help: Replace with escape sequence
1 | replacement_field = f"{'␈'}" # snapshot: invalid-character-backspace
2 | format_spec = f"{value:␈}" # snapshot: invalid-character-backspace
3 | f_string_literal = f"hello␈" # snapshot: invalid-character-backspace
- nested_f_string = f"{f'hello␈'}" # snapshot: invalid-character-backspace
4 + nested_f_string = f"{f'hello\b'}" # snapshot: invalid-character-backspace