mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-03 10:22:24 +00:00
Fix formatter generate.py
(#5829)
This commit is contained in:
parent
fb336898a5
commit
21063544f7
5 changed files with 393 additions and 152 deletions
|
@ -115,7 +115,6 @@ pub(crate) fn check_physical_lines(
|
|||
diagnostics.push(diagnostic);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -208,12 +208,7 @@ fn check_positional_args(
|
|||
(ErrorKind::ThirdArgBadAnnotation, is_traceback_type),
|
||||
];
|
||||
|
||||
for (arg, (error_info, predicate)) in positional_args
|
||||
.iter()
|
||||
.skip(1)
|
||||
.take(3)
|
||||
.zip(validations.into_iter())
|
||||
{
|
||||
for (arg, (error_info, predicate)) in positional_args.iter().skip(1).take(3).zip(validations) {
|
||||
let Some(annotation) = arg.def.annotation.as_ref() else {
|
||||
continue;
|
||||
};
|
||||
|
|
|
@ -317,7 +317,7 @@ impl From<&Configuration> for RuleTable {
|
|||
// The fixable set keeps track of which rules are fixable.
|
||||
let mut fixable_set: RuleSet = RuleSelector::All
|
||||
.into_iter()
|
||||
.chain(RuleSelector::Nursery.into_iter())
|
||||
.chain(&RuleSelector::Nursery)
|
||||
.collect();
|
||||
|
||||
// Ignores normally only subtract from the current set of selected
|
||||
|
|
9
crates/ruff_python_formatter/generate.py
Normal file → Executable file
9
crates/ruff_python_formatter/generate.py
Normal file → Executable file
|
@ -1,3 +1,5 @@
|
|||
#! /usr/bin/python
|
||||
|
||||
"""See Docs.md"""
|
||||
|
||||
# %%
|
||||
|
@ -106,11 +108,14 @@ for group, group_nodes in nodes_grouped.items():
|
|||
# Generate `FormatRule`, `AsFormat` and `IntoFormat`
|
||||
|
||||
generated = """//! This is a generated file. Don't modify it by hand! Run `crates/ruff_python_formatter/generate.py` to re-generate the file.
|
||||
#![allow(unknown_lints, clippy::default_constructed_unit_structs)]
|
||||
|
||||
use crate::context::PyFormatContext;
|
||||
use crate::{AsFormat, FormatNodeRule, IntoFormat};
|
||||
use ruff_formatter::formatter::Formatter;
|
||||
use ruff_formatter::{FormatOwnedWithRule, FormatRefWithRule, FormatResult, FormatRule};
|
||||
use rustpython_parser::ast;
|
||||
|
||||
""" # noqa: E501
|
||||
for node in nodes:
|
||||
text = f"""
|
||||
|
@ -136,7 +141,7 @@ for node in nodes:
|
|||
fn format(&self) -> Self::Format<'_> {{
|
||||
FormatRefWithRule::new(
|
||||
self,
|
||||
crate::{groups[group_for_node(node)]}::{to_camel_case(node)}::Format{node},
|
||||
crate::{groups[group_for_node(node)]}::{to_camel_case(node)}::Format{node}::default(),
|
||||
)
|
||||
}}
|
||||
}}
|
||||
|
@ -149,7 +154,7 @@ for node in nodes:
|
|||
fn into_format(self) -> Self::Format {{
|
||||
FormatOwnedWithRule::new(
|
||||
self,
|
||||
crate::{groups[group_for_node(node)]}::{to_camel_case(node)}::Format{node},
|
||||
crate::{groups[group_for_node(node)]}::{to_camel_case(node)}::Format{node}::default(),
|
||||
)
|
||||
}}
|
||||
}}
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue