mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-24 05:25:17 +00:00
Run rustfmt
on nightly to clean up erroneous comments (#5106)
## Summary This PR runs `rustfmt` with a few nightly options as a one-time fix to catch some malformatted comments. I ended up just running with: ```toml condense_wildcard_suffixes = true edition = "2021" max_width = 100 normalize_comments = true normalize_doc_attributes = true reorder_impl_items = true unstable_features = true use_field_init_shorthand = true ``` Since these all seem like reasonable things to fix, so may as well while I'm here.
This commit is contained in:
parent
9ab16fb417
commit
716cab2f19
32 changed files with 49 additions and 34 deletions
|
@ -656,7 +656,7 @@ fn handle_positional_only_arguments_separator_comment<'a>(
|
|||
/// Handles comments between the left side and the operator of a binary expression (trailing comments of the left),
|
||||
/// and trailing end-of-line comments that are on the same line as the operator.
|
||||
///
|
||||
///```python
|
||||
/// ```python
|
||||
/// a = (
|
||||
/// 5 # trailing left comment
|
||||
/// + # trailing operator comment
|
||||
|
|
|
@ -257,6 +257,7 @@ impl<'ast> PreorderVisitor<'ast> for CommentsVisitor<'ast> {
|
|||
|
||||
self.finish_node(withitem);
|
||||
}
|
||||
|
||||
fn visit_match_case(&mut self, match_case: &'ast MatchCase) {
|
||||
if self.start_node(match_case).is_traverse() {
|
||||
walk_match_case(self, match_case);
|
||||
|
|
|
@ -142,6 +142,7 @@ impl<'ast> AsFormat<PyFormatContext<'ast>> for Operator {
|
|||
|
||||
impl<'ast> IntoFormat<PyFormatContext<'ast>> for Operator {
|
||||
type Format = FormatOwnedWithRule<Operator, FormatOperator, PyFormatContext<'ast>>;
|
||||
|
||||
fn into_format(self) -> Self::Format {
|
||||
FormatOwnedWithRule::new(self, FormatOperator)
|
||||
}
|
||||
|
|
|
@ -163,6 +163,7 @@ impl NeedsParentheses for Expr {
|
|||
|
||||
impl<'ast> AsFormat<PyFormatContext<'ast>> for Expr {
|
||||
type Format<'a> = FormatRefWithRule<'a, Expr, FormatExpr, PyFormatContext<'ast>>;
|
||||
|
||||
fn format(&self) -> Self::Format<'_> {
|
||||
FormatRefWithRule::new(self, FormatExpr::default())
|
||||
}
|
||||
|
@ -170,6 +171,7 @@ impl<'ast> AsFormat<PyFormatContext<'ast>> for Expr {
|
|||
|
||||
impl<'ast> IntoFormat<PyFormatContext<'ast>> for Expr {
|
||||
type Format = FormatOwnedWithRule<Expr, FormatExpr, PyFormatContext<'ast>>;
|
||||
|
||||
fn into_format(self) -> Self::Format {
|
||||
FormatOwnedWithRule::new(self, FormatExpr::default())
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ impl FormatRule<Mod, PyFormatContext<'_>> for FormatMod {
|
|||
|
||||
impl<'ast> AsFormat<PyFormatContext<'ast>> for Mod {
|
||||
type Format<'a> = FormatRefWithRule<'a, Mod, FormatMod, PyFormatContext<'ast>>;
|
||||
|
||||
fn format(&self) -> Self::Format<'_> {
|
||||
FormatRefWithRule::new(self, FormatMod::default())
|
||||
}
|
||||
|
@ -31,6 +32,7 @@ impl<'ast> AsFormat<PyFormatContext<'ast>> for Mod {
|
|||
|
||||
impl<'ast> IntoFormat<PyFormatContext<'ast>> for Mod {
|
||||
type Format = FormatOwnedWithRule<Mod, FormatMod, PyFormatContext<'ast>>;
|
||||
|
||||
fn into_format(self) -> Self::Format {
|
||||
FormatOwnedWithRule::new(self, FormatMod::default())
|
||||
}
|
||||
|
|
|
@ -70,6 +70,7 @@ impl FormatRule<Stmt, PyFormatContext<'_>> for FormatStmt {
|
|||
|
||||
impl<'ast> AsFormat<PyFormatContext<'ast>> for Stmt {
|
||||
type Format<'a> = FormatRefWithRule<'a, Stmt, FormatStmt, PyFormatContext<'ast>>;
|
||||
|
||||
fn format(&self) -> Self::Format<'_> {
|
||||
FormatRefWithRule::new(self, FormatStmt::default())
|
||||
}
|
||||
|
@ -77,6 +78,7 @@ impl<'ast> AsFormat<PyFormatContext<'ast>> for Stmt {
|
|||
|
||||
impl<'ast> IntoFormat<PyFormatContext<'ast>> for Stmt {
|
||||
type Format = FormatOwnedWithRule<Stmt, FormatStmt, PyFormatContext<'ast>>;
|
||||
|
||||
fn into_format(self) -> Self::Format {
|
||||
FormatOwnedWithRule::new(self, FormatStmt::default())
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ use ruff_formatter::{write, Buffer, Format, FormatResult};
|
|||
use ruff_python_ast::prelude::Expr;
|
||||
use rustpython_parser::ast::StmtAssign;
|
||||
|
||||
//
|
||||
// Note: This currently does wrap but not the black way so the types below likely need to be
|
||||
// replaced entirely
|
||||
//
|
||||
|
|
|
@ -178,6 +178,7 @@ impl<'ast> AsFormat<PyFormatContext<'ast>> for Suite {
|
|||
|
||||
impl<'ast> IntoFormat<PyFormatContext<'ast>> for Suite {
|
||||
type Format = FormatOwnedWithRule<Suite, FormatSuite, PyFormatContext<'ast>>;
|
||||
|
||||
fn into_format(self) -> Self::Format {
|
||||
FormatOwnedWithRule::new(self, FormatSuite::default())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue