mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-29 05:15:12 +00:00

## Summary This PR adds support for PEP 701 in Ruff. This is a rollup PR of all the other individual PRs. The separate PRs were created for logic separation and code reviews. Refer to each pull request for a detail description on the change. Refer to the PR description for the list of pull requests within this PR. ## Test Plan ### Formatter ecosystem checks Explanation for the change in ecosystem check: https://github.com/astral-sh/ruff/pull/7597#issue-1908878183 #### `main` ``` | project | similarity index | total files | changed files | |--------------|------------------:|------------------:|------------------:| | cpython | 0.76083 | 1789 | 1631 | | django | 0.99983 | 2760 | 36 | | transformers | 0.99963 | 2587 | 319 | | twine | 1.00000 | 33 | 0 | | typeshed | 0.99983 | 3496 | 18 | | warehouse | 0.99967 | 648 | 15 | | zulip | 0.99972 | 1437 | 21 | ``` #### `dhruv/pep-701` ``` | project | similarity index | total files | changed files | |--------------|------------------:|------------------:|------------------:| | cpython | 0.76051 | 1789 | 1632 | | django | 0.99983 | 2760 | 36 | | transformers | 0.99963 | 2587 | 319 | | twine | 1.00000 | 33 | 0 | | typeshed | 0.99983 | 3496 | 18 | | warehouse | 0.99967 | 648 | 15 | | zulip | 0.99972 | 1437 | 21 | ```
44 lines
405 B
Python
44 lines
405 B
Python
# OK
|
|
a = "abc"
|
|
b = f"ghi{'jkl'}"
|
|
|
|
# Errors
|
|
c = f"def"
|
|
d = f"def" + "ghi"
|
|
e = (
|
|
f"def" +
|
|
"ghi"
|
|
)
|
|
f = (
|
|
f"a"
|
|
F"b"
|
|
"c"
|
|
rf"d"
|
|
fr"e"
|
|
)
|
|
g = f""
|
|
|
|
# OK
|
|
g = f"ghi{123:{45}}"
|
|
|
|
# Error
|
|
h = "x" "y" f"z"
|
|
|
|
v = 23.234234
|
|
|
|
# OK
|
|
f"{v:0.2f}"
|
|
f"{f'{v:0.2f}'}"
|
|
|
|
# Errors
|
|
f"{v:{f'0.2f'}}"
|
|
f"{f''}"
|
|
f"{{test}}"
|
|
f'{{ 40 }}'
|
|
f"{{a {{x}}"
|
|
f"{{{{x}}}}"
|
|
""f""
|
|
''f""
|
|
(""f""r"")
|
|
f"{v:{f"0.2f"}}"
|
|
f"\{{x}}"
|