mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-09 18:02:19 +00:00
Standardise ruff config (#15558)
This commit is contained in:
parent
c616650dfa
commit
023c52d82b
5 changed files with 77 additions and 81 deletions
|
@ -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))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue