mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-07 21:25:08 +00:00
Standardise ruff config (#15558)
This commit is contained in:
parent
c616650dfa
commit
023c52d82b
5 changed files with 77 additions and 81 deletions
|
@ -174,7 +174,7 @@ def write_owned_enum(out: list[str], groups: list[Group]) -> None:
|
|||
""")
|
||||
for node in group.nodes:
|
||||
out.append(
|
||||
f"""{group.owned_enum_ty}::{node.variant}(node) => node.visit_source_order(visitor),"""
|
||||
f"{group.owned_enum_ty}::{node.variant}(node) => node.visit_source_order(visitor),"
|
||||
)
|
||||
out.append("""
|
||||
}
|
||||
|
@ -234,7 +234,7 @@ def write_ref_enum(out: list[str], groups: list[Group]) -> None:
|
|||
""")
|
||||
for node in group.nodes:
|
||||
out.append(
|
||||
f"""{group.owned_enum_ty}::{node.variant}(node) => {group.ref_enum_ty}::{node.variant}(node),"""
|
||||
f"{group.owned_enum_ty}::{node.variant}(node) => {group.ref_enum_ty}::{node.variant}(node),"
|
||||
)
|
||||
out.append("""
|
||||
}
|
||||
|
@ -311,7 +311,7 @@ def write_anynoderef(out: list[str], groups: list[Group]) -> None:
|
|||
""")
|
||||
for node in group.nodes:
|
||||
out.append(
|
||||
f"""{group.owned_enum_ty}::{node.variant}(node) => AnyNodeRef::{node.name}(node),"""
|
||||
f"{group.owned_enum_ty}::{node.variant}(node) => AnyNodeRef::{node.name}(node),"
|
||||
)
|
||||
out.append("""
|
||||
}
|
||||
|
@ -326,7 +326,7 @@ def write_anynoderef(out: list[str], groups: list[Group]) -> None:
|
|||
""")
|
||||
for node in group.nodes:
|
||||
out.append(
|
||||
f"""{group.ref_enum_ty}::{node.variant}(node) => AnyNodeRef::{node.name}(node),"""
|
||||
f"{group.ref_enum_ty}::{node.variant}(node) => AnyNodeRef::{node.name}(node),"
|
||||
)
|
||||
out.append("""
|
||||
}
|
||||
|
@ -365,7 +365,7 @@ def write_anynoderef(out: list[str], groups: list[Group]) -> None:
|
|||
for group in groups:
|
||||
for node in group.nodes:
|
||||
out.append(
|
||||
f"""AnyNodeRef::{node.name}(node) => std::ptr::NonNull::from(*node).cast(),"""
|
||||
f"AnyNodeRef::{node.name}(node) => std::ptr::NonNull::from(*node).cast(),"
|
||||
)
|
||||
out.append("""
|
||||
}
|
||||
|
@ -385,7 +385,7 @@ def write_anynoderef(out: list[str], groups: list[Group]) -> None:
|
|||
for group in groups:
|
||||
for node in group.nodes:
|
||||
out.append(
|
||||
f"""AnyNodeRef::{node.name}(node) => node.visit_source_order(visitor),"""
|
||||
f"AnyNodeRef::{node.name}(node) => node.visit_source_order(visitor),"
|
||||
)
|
||||
out.append("""
|
||||
}
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -58,6 +58,7 @@ include = [
|
|||
]
|
||||
|
||||
[tool.ruff]
|
||||
target-version = "py38"
|
||||
extend-exclude = [
|
||||
"crates/red_knot_vendored/vendor/",
|
||||
"crates/ruff/resources/",
|
||||
|
@ -67,14 +68,33 @@ extend-exclude = [
|
|||
]
|
||||
|
||||
[tool.ruff.lint]
|
||||
select = [
|
||||
"E", # pycodestyle (error)
|
||||
"F", # pyflakes
|
||||
"B", # bugbear
|
||||
"B9",
|
||||
"C4", # flake8-comprehensions
|
||||
"SIM", # flake8-simplify
|
||||
"I", # isort
|
||||
"UP", # pyupgrade
|
||||
"PIE", # flake8-pie
|
||||
"PGH", # pygrep-hooks
|
||||
"PYI", # flake8-pyi
|
||||
"RUF",
|
||||
]
|
||||
|
||||
ignore = [
|
||||
# Conflicts with the formatter
|
||||
"COM812", "ISC001"
|
||||
]
|
||||
extend-select = [
|
||||
"I",
|
||||
# only relevant if you run a script with `python -0`,
|
||||
# which seems unlikely for any of the scripts in this repo
|
||||
"B011",
|
||||
# Leave it to the formatter to split long lines and
|
||||
# the judgement of all of us.
|
||||
"E501"
|
||||
]
|
||||
|
||||
[tool.ruff.lint.isort]
|
||||
required-imports = ["from __future__ import annotations"]
|
||||
|
||||
[tool.black]
|
||||
force-exclude = '''
|
||||
/(
|
||||
|
|
|
@ -449,7 +449,7 @@ async def main(
|
|||
|
||||
if matches is None:
|
||||
# Handle case where there are no regex matches e.g.
|
||||
# + "?application=AIRFLOW&authenticator=TEST_AUTH&role=TEST_ROLE&warehouse=TEST_WAREHOUSE" # noqa: E501
|
||||
# + "?application=AIRFLOW&authenticator=TEST_AUTH&role=TEST_ROLE&warehouse=TEST_WAREHOUSE"
|
||||
# Which was found in local testing
|
||||
continue
|
||||
|
||||
|
|
|
@ -8,29 +8,4 @@ requires-python = ">=3.11"
|
|||
line-length = 88
|
||||
|
||||
[tool.ruff]
|
||||
line-length = 88
|
||||
|
||||
[tool.ruff.lint]
|
||||
select = [
|
||||
"E", # pycodestyle (error)
|
||||
"F", # pyflakes
|
||||
"B", # bugbear
|
||||
"B9",
|
||||
"C4", # flake8-comprehensions
|
||||
"SIM", # flake8-simplify
|
||||
"I", # isort
|
||||
"UP", # pyupgrade
|
||||
"PIE", # flake8-pie
|
||||
"PGH", # pygrep-hooks
|
||||
"PYI", # flake8-pyi
|
||||
"RUF",
|
||||
]
|
||||
|
||||
ignore = [
|
||||
# only relevant if you run a script with `python -0`,
|
||||
# which seems unlikely for any of the scripts in this directory
|
||||
"B011"
|
||||
]
|
||||
|
||||
[tool.ruff.lint.isort]
|
||||
required-imports = ["from __future__ import annotations"]
|
||||
extend = "../pyproject.toml"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue