|
| 1 | +--- |
| 2 | +source: crates/ruff_python_formatter/tests/fixtures.rs |
| 3 | +input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/fstring_preview.py |
| 4 | +snapshot_kind: text |
| 5 | +--- |
| 6 | +## Input |
| 7 | +```python |
| 8 | +# This test is in its own file because it results in AST changes on stable. |
| 9 | +# We don't plan to fix it on stable because we plan on promoting f-string formatting soon. |
| 10 | +
|
| 11 | +# Regression test for https://github.com/astral-sh/ruff/issues/14766 |
| 12 | +# Don't change the casing of the escaped characters in the f-string because it would be observable in the debug expression. |
| 13 | +# >>> f"{r"\xFF"=}" |
| 14 | +# 'r"ÿ"=\'\\\\xFF\'' |
| 15 | +# >>> f"{r"\xff"=}" |
| 16 | +# 'r"ÿ"=\'\\\\xff\'' |
| 17 | +f"{r"\xFF"=}" |
| 18 | +f"{r"\xff"=}" |
| 19 | +
|
| 20 | +
|
| 21 | +# Test for https://github.com/astral-sh/ruff/issues/14926 |
| 22 | +# We could change the casing of the escaped characters in non-raw f-string because Python interprets the inner string |
| 23 | +# before printing it as a debug expression. For now, we decided not to change the casing because it's fairly complicated |
| 24 | +# to implement and it seems uncommon (debug expressions are uncommon, escapes are uncommon). |
| 25 | +# These two strings could be formatted to the same output but we currently don't do that. |
| 26 | +f"{"\xFF\N{space}"=}" |
| 27 | +f"{"\xff\N{SPACE}"=}" |
| 28 | +``` |
| 29 | + |
| 30 | +## Outputs |
| 31 | +### Output 1 |
| 32 | +``` |
| 33 | +indent-style = space |
| 34 | +line-width = 88 |
| 35 | +indent-width = 4 |
| 36 | +quote-style = Double |
| 37 | +line-ending = LineFeed |
| 38 | +magic-trailing-comma = Respect |
| 39 | +docstring-code = Disabled |
| 40 | +docstring-code-line-width = "dynamic" |
| 41 | +preview = Enabled |
| 42 | +target_version = Py39 |
| 43 | +source_type = Python |
| 44 | +``` |
| 45 | + |
| 46 | +```python |
| 47 | +# This test is in its own file because it results in AST changes on stable. |
| 48 | +# We don't plan to fix it on stable because we plan on promoting f-string formatting soon. |
| 49 | +
|
| 50 | +# Regression test for https://github.com/astral-sh/ruff/issues/14766 |
| 51 | +# Don't change the casing of the escaped characters in the f-string because it would be observable in the debug expression. |
| 52 | +# >>> f"{r"\xFF"=}" |
| 53 | +# 'r"ÿ"=\'\\\\xFF\'' |
| 54 | +# >>> f"{r"\xff"=}" |
| 55 | +# 'r"ÿ"=\'\\\\xff\'' |
| 56 | +f"{r"\xFF"=}" |
| 57 | +f"{r"\xff"=}" |
| 58 | +
|
| 59 | +
|
| 60 | +# Test for https://github.com/astral-sh/ruff/issues/14926 |
| 61 | +# We could change the casing of the escaped characters in non-raw f-string because Python interprets the inner string |
| 62 | +# before printing it as a debug expression. For now, we decided not to change the casing because it's fairly complicated |
| 63 | +# to implement and it seems uncommon (debug expressions are uncommon, escapes are uncommon). |
| 64 | +# These two strings could be formatted to the same output but we currently don't do that. |
| 65 | +f"{"\xFF\N{space}"=}" |
| 66 | +f"{"\xff\N{SPACE}"=}" |
| 67 | +``` |
0 commit comments