Standardise ruff config (#15558)

This commit is contained in:
Calum Young 2025-01-21 11:09:11 +00:00 committed by GitHub
parent c616650dfa
commit 023c52d82b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 77 additions and 81 deletions

View file

@ -3,6 +3,7 @@
"""See CONTRIBUTING.md"""
# %%
from __future__ import annotations
import re
from collections import defaultdict
@ -34,8 +35,8 @@ nodes = []
for node_line in node_lines:
node = node_line.split("(")[1].split(")")[0].split("::")[-1].removeprefix("&'a ")
# `FString` has a custom implementation while the formatting for
# `FStringLiteralElement`, `FStringFormatSpec` and `FStringExpressionElement` are handled by the `FString`
# implementation.
# `FStringLiteralElement`, `FStringFormatSpec` and `FStringExpressionElement` are
# handled by the `FString` implementation.
if node in (
"FStringLiteralElement",
"FStringExpressionElement",
@ -112,7 +113,7 @@ for group, group_nodes in nodes_grouped.items():
write!(f, [verbatim_text(item)])
}}
}}
""".strip() # noqa: E501
""".strip()
node_path.write_text(rustfmt(code))
@ -127,7 +128,7 @@ use crate::{AsFormat, FormatNodeRule, IntoFormat, PyFormatter};
use ruff_formatter::{FormatOwnedWithRule, FormatRefWithRule, FormatResult, FormatRule};
use ruff_python_ast as ast;
""" # noqa: E501
"""
for node in nodes:
text = f"""
impl FormatRule<ast::{node}, PyFormatContext<'_>>
@ -169,7 +170,7 @@ for node in nodes:
)
}}
}}
""" # noqa: E501
"""
generated += text
out.write_text(rustfmt(generated))