diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 484b3b3519..d4232fb7bd 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -495,7 +495,7 @@ jobs: persist-credentials: false - uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8 - name: "Install Rust toolchain" - run: rustup component add rustfmt + run: rustup show # Run all code generation scripts, and verify that the current output is # already checked into git. - run: python crates/ruff_python_ast/generate.py @@ -504,12 +504,10 @@ jobs: # Verify that adding a plugin or rule produces clean code. - run: ./scripts/add_rule.py --name DoTheThing --prefix F --code 999 --linter pyflakes - run: cargo check - - run: cargo fmt --all --check - run: | ./scripts/add_plugin.py test --url https://pypi.org/project/-test/0.1.0/ --prefix TST ./scripts/add_rule.py --name FirstRule --prefix TST --code 001 --linter test - run: cargo check - - run: cargo fmt --all --check ecosystem: name: "ecosystem" diff --git a/Cargo.toml b/Cargo.toml index 2704d59a46..285bbd7bf8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ members = ["crates/*"] resolver = "2" [workspace.package] -edition = "2021" +edition = "2024" rust-version = "1.85" homepage = "https://docs.astral.sh/ruff" documentation = "https://docs.astral.sh/ruff" diff --git a/crates/ruff/src/args.rs b/crates/ruff/src/args.rs index fb2f9a273d..45db84d053 100644 --- a/crates/ruff/src/args.rs +++ b/crates/ruff/src/args.rs @@ -8,7 +8,7 @@ use std::sync::Arc; use crate::commands::completions::config::{OptionString, OptionStringParser}; use anyhow::bail; use clap::builder::{TypedValueParser, ValueParserFactory}; -use clap::{command, Parser, Subcommand}; +use clap::{Parser, Subcommand, command}; use colored::Colorize; use itertools::Itertools; use path_absolutize::path_dedot; @@ -1126,10 +1126,10 @@ impl std::fmt::Display for FormatRangeParseError { write!( f, "the start position '{start_invalid}' is greater than the end position '{end_invalid}'.\n {tip} Try switching start and end: '{end}-{start}'", - start_invalid=start.to_string().bold().yellow(), - end_invalid=end.to_string().bold().yellow(), - start=start.to_string().green().bold(), - end=end.to_string().green().bold() + start_invalid = start.to_string().bold().yellow(), + end_invalid = end.to_string().bold().yellow(), + start = start.to_string().green().bold(), + end = end.to_string().green().bold() ) } FormatRangeParseError::InvalidStart(inner) => inner.write(f, true), @@ -1230,30 +1230,36 @@ impl LineColumnParseError { match self { LineColumnParseError::ColumnParseError(inner) => { - write!(f, "the {range}s column is not a valid number ({inner})'\n {tip} The format is 'line:column'.") + write!( + f, + "the {range}s column is not a valid number ({inner})'\n {tip} The format is 'line:column'." + ) } LineColumnParseError::LineParseError(inner) => { - write!(f, "the {range} line is not a valid number ({inner})\n {tip} The format is 'line:column'.") + write!( + f, + "the {range} line is not a valid number ({inner})\n {tip} The format is 'line:column'." + ) } LineColumnParseError::ZeroColumnIndex { line } => { write!( f, "the {range} column is 0, but it should be 1 or greater.\n {tip} The column numbers start at 1.\n {tip} Try {suggestion} instead.", - suggestion=format!("{line}:1").green().bold() + suggestion = format!("{line}:1").green().bold() ) } LineColumnParseError::ZeroLineIndex { column } => { write!( f, "the {range} line is 0, but it should be 1 or greater.\n {tip} The line numbers start at 1.\n {tip} Try {suggestion} instead.", - suggestion=format!("1:{column}").green().bold() + suggestion = format!("1:{column}").green().bold() ) } LineColumnParseError::ZeroLineAndColumnIndex => { write!( f, "the {range} line and column are both 0, but they should be 1 or greater.\n {tip} The line and column numbers start at 1.\n {tip} Try {suggestion} instead.", - suggestion="1:1".to_string().green().bold() + suggestion = "1:1".to_string().green().bold() ) } } diff --git a/crates/ruff/src/cache.rs b/crates/ruff/src/cache.rs index 99eed7cbaf..056c7420b0 100644 --- a/crates/ruff/src/cache.rs +++ b/crates/ruff/src/cache.rs @@ -3,8 +3,8 @@ use std::fs::{self, File}; use std::hash::Hasher; use std::io::{self, BufReader, Write}; use std::path::{Path, PathBuf}; -use std::sync::atomic::{AtomicU64, Ordering}; use std::sync::Mutex; +use std::sync::atomic::{AtomicU64, Ordering}; use std::time::{Duration, SystemTime}; use anyhow::{Context, Result}; @@ -22,13 +22,13 @@ use ruff_cache::{CacheKey, CacheKeyHasher}; use ruff_diagnostics::Fix; use ruff_linter::message::{DiagnosticMessage, Message}; use ruff_linter::package::PackageRoot; -use ruff_linter::{warn_user, VERSION}; +use ruff_linter::{VERSION, warn_user}; use ruff_macros::CacheKey; use ruff_notebook::NotebookIndex; use ruff_source_file::SourceFileBuilder; use ruff_text_size::{TextRange, TextSize}; -use ruff_workspace::resolver::Resolver; use ruff_workspace::Settings; +use ruff_workspace::resolver::Resolver; use crate::diagnostics::Diagnostics; @@ -597,7 +597,7 @@ mod tests { use std::time::SystemTime; use anyhow::Result; - use filetime::{set_file_mtime, FileTime}; + use filetime::{FileTime, set_file_mtime}; use itertools::Itertools; use ruff_linter::settings::LinterSettings; use test_case::test_case; @@ -612,8 +612,8 @@ mod tests { use crate::cache::{self, FileCache, FileCacheData, FileCacheKey}; use crate::cache::{Cache, RelativePathBuf}; - use crate::commands::format::{format_path, FormatCommandError, FormatMode, FormatResult}; - use crate::diagnostics::{lint_path, Diagnostics}; + use crate::commands::format::{FormatCommandError, FormatMode, FormatResult, format_path}; + use crate::diagnostics::{Diagnostics, lint_path}; #[test_case("../ruff_linter/resources/test/fixtures", "ruff_tests/cache_same_results_ruff_linter"; "ruff_linter_fixtures")] #[test_case("../ruff_notebook/resources/test/fixtures", "ruff_tests/cache_same_results_ruff_notebook"; "ruff_notebook_fixtures")] diff --git a/crates/ruff/src/commands/add_noqa.rs b/crates/ruff/src/commands/add_noqa.rs index c5a417ec3c..d5eaeb0170 100644 --- a/crates/ruff/src/commands/add_noqa.rs +++ b/crates/ruff/src/commands/add_noqa.rs @@ -11,7 +11,7 @@ use ruff_linter::source_kind::SourceKind; use ruff_linter::warn_user_once; use ruff_python_ast::{PySourceType, SourceType}; use ruff_workspace::resolver::{ - match_exclusion, python_files_in_path, PyprojectConfig, ResolvedFile, + PyprojectConfig, ResolvedFile, match_exclusion, python_files_in_path, }; use crate::args::ConfigArguments; diff --git a/crates/ruff/src/commands/analyze_graph.rs b/crates/ruff/src/commands/analyze_graph.rs index d0bf72edf7..75ff28d0dc 100644 --- a/crates/ruff/src/commands/analyze_graph.rs +++ b/crates/ruff/src/commands/analyze_graph.rs @@ -1,6 +1,6 @@ use crate::args::{AnalyzeGraphArgs, ConfigArguments}; use crate::resolve::resolve; -use crate::{resolve_default_files, ExitStatus}; +use crate::{ExitStatus, resolve_default_files}; use anyhow::Result; use log::{debug, warn}; use path_absolutize::CWD; @@ -9,7 +9,7 @@ use ruff_graph::{Direction, ImportMap, ModuleDb, ModuleImports}; use ruff_linter::package::PackageRoot; use ruff_linter::{warn_user, warn_user_once}; use ruff_python_ast::{PySourceType, SourceType}; -use ruff_workspace::resolver::{match_exclusion, python_files_in_path, ResolvedFile}; +use ruff_workspace::resolver::{ResolvedFile, match_exclusion, python_files_in_path}; use rustc_hash::FxHashMap; use std::io::Write; use std::path::{Path, PathBuf}; diff --git a/crates/ruff/src/commands/check.rs b/crates/ruff/src/commands/check.rs index 9b7104e4dc..72ae7162d9 100644 --- a/crates/ruff/src/commands/check.rs +++ b/crates/ruff/src/commands/check.rs @@ -17,12 +17,12 @@ use ruff_linter::message::Message; use ruff_linter::package::PackageRoot; use ruff_linter::registry::Rule; use ruff_linter::settings::types::UnsafeFixes; -use ruff_linter::settings::{flags, LinterSettings}; -use ruff_linter::{fs, warn_user_once, IOError}; +use ruff_linter::settings::{LinterSettings, flags}; +use ruff_linter::{IOError, fs, warn_user_once}; use ruff_source_file::SourceFileBuilder; use ruff_text_size::{TextRange, TextSize}; use ruff_workspace::resolver::{ - match_exclusion, python_files_in_path, PyprojectConfig, ResolvedFile, + PyprojectConfig, ResolvedFile, match_exclusion, python_files_in_path, }; use crate::args::ConfigArguments; @@ -228,9 +228,9 @@ mod test { use ruff_linter::message::{Emitter, EmitterContext, TextEmitter}; use ruff_linter::registry::Rule; use ruff_linter::settings::types::UnsafeFixes; - use ruff_linter::settings::{flags, LinterSettings}; - use ruff_workspace::resolver::{PyprojectConfig, PyprojectDiscoveryStrategy}; + use ruff_linter::settings::{LinterSettings, flags}; use ruff_workspace::Settings; + use ruff_workspace::resolver::{PyprojectConfig, PyprojectDiscoveryStrategy}; use crate::args::ConfigArguments; diff --git a/crates/ruff/src/commands/check_stdin.rs b/crates/ruff/src/commands/check_stdin.rs index 4e7be0b540..4b01943353 100644 --- a/crates/ruff/src/commands/check_stdin.rs +++ b/crates/ruff/src/commands/check_stdin.rs @@ -4,10 +4,10 @@ use anyhow::Result; use ruff_linter::package::PackageRoot; use ruff_linter::packaging; use ruff_linter::settings::flags; -use ruff_workspace::resolver::{match_exclusion, python_file_at_path, PyprojectConfig, Resolver}; +use ruff_workspace::resolver::{PyprojectConfig, Resolver, match_exclusion, python_file_at_path}; use crate::args::ConfigArguments; -use crate::diagnostics::{lint_stdin, Diagnostics}; +use crate::diagnostics::{Diagnostics, lint_stdin}; use crate::stdin::{parrot_stdin, read_from_stdin}; /// Run the linter over a single file, read from `stdin`. diff --git a/crates/ruff/src/commands/config.rs b/crates/ruff/src/commands/config.rs index 98bd9d70ae..f6c0054839 100644 --- a/crates/ruff/src/commands/config.rs +++ b/crates/ruff/src/commands/config.rs @@ -1,4 +1,4 @@ -use anyhow::{anyhow, Result}; +use anyhow::{Result, anyhow}; use crate::args::HelpFormat; diff --git a/crates/ruff/src/commands/format.rs b/crates/ruff/src/commands/format.rs index 57414c249d..a09fb9b804 100644 --- a/crates/ruff/src/commands/format.rs +++ b/crates/ruff/src/commands/format.rs @@ -1,7 +1,7 @@ use std::fmt::{Display, Formatter}; use std::fs::File; use std::io; -use std::io::{stderr, stdout, Write}; +use std::io::{Write, stderr, stdout}; use std::path::{Path, PathBuf}; use std::time::Instant; @@ -16,7 +16,7 @@ use rustc_hash::FxHashSet; use thiserror::Error; use tracing::debug; -use ruff_db::panic::{catch_unwind, PanicError}; +use ruff_db::panic::{PanicError, catch_unwind}; use ruff_diagnostics::SourceMap; use ruff_linter::fs; use ruff_linter::logging::{DisplayParseError, LogLevel}; @@ -26,16 +26,16 @@ use ruff_linter::rules::flake8_quotes::settings::Quote; use ruff_linter::source_kind::{SourceError, SourceKind}; use ruff_linter::warn_user_once; use ruff_python_ast::{PySourceType, SourceType}; -use ruff_python_formatter::{format_module_source, format_range, FormatModuleError, QuoteStyle}; +use ruff_python_formatter::{FormatModuleError, QuoteStyle, format_module_source, format_range}; use ruff_source_file::LineIndex; use ruff_text_size::{TextLen, TextRange, TextSize}; -use ruff_workspace::resolver::{match_exclusion, python_files_in_path, ResolvedFile, Resolver}; use ruff_workspace::FormatterSettings; +use ruff_workspace::resolver::{ResolvedFile, Resolver, match_exclusion, python_files_in_path}; use crate::args::{ConfigArguments, FormatArguments, FormatRange}; use crate::cache::{Cache, FileCacheKey, PackageCacheMap, PackageCaches}; use crate::resolve::resolve; -use crate::{resolve_default_files, ExitStatus}; +use crate::{ExitStatus, resolve_default_files}; #[derive(Debug, Copy, Clone, is_macro::Is)] pub(crate) enum FormatMode { @@ -821,9 +821,14 @@ pub(super) fn warn_incompatible_formatter_settings(resolver: &Resolver) { .collect(); rule_names.sort(); if let [rule] = rule_names.as_slice() { - warn_user_once!("The following rule may cause conflicts when used with the formatter: {rule}. To avoid unexpected behavior, we recommend disabling this rule, either by removing it from the `select` or `extend-select` configuration, or adding it to the `ignore` configuration."); + warn_user_once!( + "The following rule may cause conflicts when used with the formatter: {rule}. To avoid unexpected behavior, we recommend disabling this rule, either by removing it from the `select` or `extend-select` configuration, or adding it to the `ignore` configuration." + ); } else { - warn_user_once!("The following rules may cause conflicts when used with the formatter: {}. To avoid unexpected behavior, we recommend disabling these rules, either by removing them from the `select` or `extend-select` configuration, or adding them to the `ignore` configuration.", rule_names.join(", ")); + warn_user_once!( + "The following rules may cause conflicts when used with the formatter: {}. To avoid unexpected behavior, we recommend disabling these rules, either by removing them from the `select` or `extend-select` configuration, or adding them to the `ignore` configuration.", + rule_names.join(", ") + ); } } @@ -833,7 +838,9 @@ pub(super) fn warn_incompatible_formatter_settings(resolver: &Resolver) { if setting.linter.rules.enabled(Rule::TabIndentation) && setting.formatter.indent_style.is_tab() { - warn_user_once!("The `format.indent-style=\"tab\"` option is incompatible with `W191`, which lints against all uses of tabs. We recommend disabling these rules when using the formatter, which enforces a consistent indentation style. Alternatively, set the `format.indent-style` option to `\"space\"`."); + warn_user_once!( + "The `format.indent-style=\"tab\"` option is incompatible with `W191`, which lints against all uses of tabs. We recommend disabling these rules when using the formatter, which enforces a consistent indentation style. Alternatively, set the `format.indent-style` option to `\"space\"`." + ); } if !setting @@ -846,14 +853,18 @@ pub(super) fn warn_incompatible_formatter_settings(resolver: &Resolver) { .enabled(Rule::MultiLineImplicitStringConcatenation) && !setting.linter.flake8_implicit_str_concat.allow_multiline { - warn_user_once!("The `lint.flake8-implicit-str-concat.allow-multiline = false` option is incompatible with the formatter unless `ISC001` is enabled. We recommend enabling `ISC001` or setting `allow-multiline=true`."); + warn_user_once!( + "The `lint.flake8-implicit-str-concat.allow-multiline = false` option is incompatible with the formatter unless `ISC001` is enabled. We recommend enabling `ISC001` or setting `allow-multiline=true`." + ); } // Validate all rules that rely on tab styles. if setting.linter.rules.enabled(Rule::DocstringTabIndentation) && setting.formatter.indent_style.is_tab() { - warn_user_once!("The `format.indent-style=\"tab\"` option is incompatible with `D206`, with requires space-based indentation. We recommend disabling these rules when using the formatter, which enforces a consistent indentation style. Alternatively, set the `format.indent-style` option to `\"space\"`."); + warn_user_once!( + "The `format.indent-style=\"tab\"` option is incompatible with `D206`, with requires space-based indentation. We recommend disabling these rules when using the formatter, which enforces a consistent indentation style. Alternatively, set the `format.indent-style` option to `\"space\"`." + ); } // Validate all rules that rely on custom indent widths. @@ -862,7 +873,9 @@ pub(super) fn warn_incompatible_formatter_settings(resolver: &Resolver) { Rule::IndentationWithInvalidMultipleComment, ]) && setting.formatter.indent_width.value() != 4 { - warn_user_once!("The `format.indent-width` option with a value other than 4 is incompatible with `E111` and `E114`. We recommend disabling these rules when using the formatter, which enforces a consistent indentation width. Alternatively, set the `format.indent-width` option to `4`."); + warn_user_once!( + "The `format.indent-width` option with a value other than 4 is incompatible with `E111` and `E114`. We recommend disabling these rules when using the formatter, which enforces a consistent indentation width. Alternatively, set the `format.indent-width` option to `4`." + ); } // Validate all rules that rely on quote styles. @@ -876,10 +889,14 @@ pub(super) fn warn_incompatible_formatter_settings(resolver: &Resolver) { setting.formatter.quote_style, ) { (Quote::Double, QuoteStyle::Single) => { - warn_user_once!("The `flake8-quotes.inline-quotes=\"double\"` option is incompatible with the formatter's `format.quote-style=\"single\"`. We recommend disabling `Q000` and `Q003` when using the formatter, which enforces a consistent quote style. Alternatively, set both options to either `\"single\"` or `\"double\"`."); + warn_user_once!( + "The `flake8-quotes.inline-quotes=\"double\"` option is incompatible with the formatter's `format.quote-style=\"single\"`. We recommend disabling `Q000` and `Q003` when using the formatter, which enforces a consistent quote style. Alternatively, set both options to either `\"single\"` or `\"double\"`." + ); } (Quote::Single, QuoteStyle::Double) => { - warn_user_once!("The `flake8-quotes.inline-quotes=\"single\"` option is incompatible with the formatter's `format.quote-style=\"double\"`. We recommend disabling `Q000` and `Q003` when using the formatter, which enforces a consistent quote style. Alternatively, set both options to either `\"single\"` or `\"double\"`."); + warn_user_once!( + "The `flake8-quotes.inline-quotes=\"single\"` option is incompatible with the formatter's `format.quote-style=\"double\"`. We recommend disabling `Q000` and `Q003` when using the formatter, which enforces a consistent quote style. Alternatively, set both options to either `\"single\"` or `\"double\"`." + ); } _ => {} } @@ -892,7 +909,9 @@ pub(super) fn warn_incompatible_formatter_settings(resolver: &Resolver) { QuoteStyle::Single | QuoteStyle::Double ) { - warn_user_once!("The `flake8-quotes.multiline-quotes=\"single\"` option is incompatible with the formatter. We recommend disabling `Q001` when using the formatter, which enforces double quotes for multiline strings. Alternatively, set the `flake8-quotes.multiline-quotes` option to `\"double\"`.`"); + warn_user_once!( + "The `flake8-quotes.multiline-quotes=\"single\"` option is incompatible with the formatter. We recommend disabling `Q001` when using the formatter, which enforces double quotes for multiline strings. Alternatively, set the `flake8-quotes.multiline-quotes` option to `\"double\"`.`" + ); } if setting.linter.rules.enabled(Rule::BadQuotesDocstring) @@ -902,7 +921,9 @@ pub(super) fn warn_incompatible_formatter_settings(resolver: &Resolver) { QuoteStyle::Single | QuoteStyle::Double ) { - warn_user_once!("The `flake8-quotes.docstring-quotes=\"single\"` option is incompatible with the formatter. We recommend disabling `Q002` when using the formatter, which enforces double quotes for docstrings. Alternatively, set the `flake8-quotes.docstring-quotes` option to `\"double\"`.`"); + warn_user_once!( + "The `flake8-quotes.docstring-quotes=\"single\"` option is incompatible with the formatter. We recommend disabling `Q002` when using the formatter, which enforces double quotes for docstrings. Alternatively, set the `flake8-quotes.docstring-quotes` option to `\"double\"`.`" + ); } // Validate all isort settings. @@ -910,12 +931,16 @@ pub(super) fn warn_incompatible_formatter_settings(resolver: &Resolver) { // The formatter removes empty lines if the value is larger than 2 but always inserts a empty line after imports. // Two empty lines are okay because `isort` only uses this setting for top-level imports (not in nested blocks). if !matches!(setting.linter.isort.lines_after_imports, 1 | 2 | -1) { - warn_user_once!("The isort option `isort.lines-after-imports` with a value other than `-1`, `1` or `2` is incompatible with the formatter. To avoid unexpected behavior, we recommend setting the option to one of: `2`, `1`, or `-1` (default)."); + warn_user_once!( + "The isort option `isort.lines-after-imports` with a value other than `-1`, `1` or `2` is incompatible with the formatter. To avoid unexpected behavior, we recommend setting the option to one of: `2`, `1`, or `-1` (default)." + ); } // Values larger than two get reduced to one line by the formatter if the import is in a nested block. if setting.linter.isort.lines_between_types > 1 { - warn_user_once!("The isort option `isort.lines-between-types` with a value greater than 1 is incompatible with the formatter. To avoid unexpected behavior, we recommend setting the option to one of: `1` or `0` (default)."); + warn_user_once!( + "The isort option `isort.lines-between-types` with a value greater than 1 is incompatible with the formatter. To avoid unexpected behavior, we recommend setting the option to one of: `1` or `0` (default)." + ); } // isort inserts a trailing comma which the formatter preserves, but only if `skip-magic-trailing-comma` isn't false. @@ -924,11 +949,15 @@ pub(super) fn warn_incompatible_formatter_settings(resolver: &Resolver) { && !setting.linter.isort.force_single_line { if setting.linter.isort.force_wrap_aliases { - warn_user_once!("The isort option `isort.force-wrap-aliases` is incompatible with the formatter `format.skip-magic-trailing-comma=true` option. To avoid unexpected behavior, we recommend either setting `isort.force-wrap-aliases=false` or `format.skip-magic-trailing-comma=false`."); + warn_user_once!( + "The isort option `isort.force-wrap-aliases` is incompatible with the formatter `format.skip-magic-trailing-comma=true` option. To avoid unexpected behavior, we recommend either setting `isort.force-wrap-aliases=false` or `format.skip-magic-trailing-comma=false`." + ); } if setting.linter.isort.split_on_trailing_comma { - warn_user_once!("The isort option `isort.split-on-trailing-comma` is incompatible with the formatter `format.skip-magic-trailing-comma=true` option. To avoid unexpected behavior, we recommend either setting `isort.split-on-trailing-comma=false` or `format.skip-magic-trailing-comma=false`."); + warn_user_once!( + "The isort option `isort.split-on-trailing-comma` is incompatible with the formatter `format.skip-magic-trailing-comma=true` option. To avoid unexpected behavior, we recommend either setting `isort.split-on-trailing-comma=false` or `format.skip-magic-trailing-comma=false`." + ); } } } diff --git a/crates/ruff/src/commands/format_stdin.rs b/crates/ruff/src/commands/format_stdin.rs index 9c2d8ff3e0..f5b8ea6c60 100644 --- a/crates/ruff/src/commands/format_stdin.rs +++ b/crates/ruff/src/commands/format_stdin.rs @@ -6,17 +6,17 @@ use log::error; use ruff_linter::source_kind::SourceKind; use ruff_python_ast::{PySourceType, SourceType}; -use ruff_workspace::resolver::{match_exclusion, python_file_at_path, Resolver}; use ruff_workspace::FormatterSettings; +use ruff_workspace::resolver::{Resolver, match_exclusion, python_file_at_path}; +use crate::ExitStatus; use crate::args::{ConfigArguments, FormatArguments, FormatRange}; use crate::commands::format::{ - format_source, warn_incompatible_formatter_settings, FormatCommandError, FormatMode, - FormatResult, FormattedSource, + FormatCommandError, FormatMode, FormatResult, FormattedSource, format_source, + warn_incompatible_formatter_settings, }; use crate::resolve::resolve; use crate::stdin::{parrot_stdin, read_from_stdin}; -use crate::ExitStatus; /// Run the formatter over a single file, read from `stdin`. pub(crate) fn format_stdin( diff --git a/crates/ruff/src/commands/show_files.rs b/crates/ruff/src/commands/show_files.rs index f21a9aa943..7c74837fd3 100644 --- a/crates/ruff/src/commands/show_files.rs +++ b/crates/ruff/src/commands/show_files.rs @@ -5,7 +5,7 @@ use anyhow::Result; use itertools::Itertools; use ruff_linter::warn_user_once; -use ruff_workspace::resolver::{python_files_in_path, PyprojectConfig, ResolvedFile}; +use ruff_workspace::resolver::{PyprojectConfig, ResolvedFile, python_files_in_path}; use crate::args::ConfigArguments; diff --git a/crates/ruff/src/commands/show_settings.rs b/crates/ruff/src/commands/show_settings.rs index 679c2733df..ec4b0d5482 100644 --- a/crates/ruff/src/commands/show_settings.rs +++ b/crates/ruff/src/commands/show_settings.rs @@ -1,10 +1,10 @@ use std::io::Write; use std::path::PathBuf; -use anyhow::{bail, Result}; +use anyhow::{Result, bail}; use itertools::Itertools; -use ruff_workspace::resolver::{python_files_in_path, PyprojectConfig, ResolvedFile}; +use ruff_workspace::resolver::{PyprojectConfig, ResolvedFile, python_files_in_path}; use crate::args::ConfigArguments; diff --git a/crates/ruff/src/diagnostics.rs b/crates/ruff/src/diagnostics.rs index 4610eca5c4..5ce39f49a8 100644 --- a/crates/ruff/src/diagnostics.rs +++ b/crates/ruff/src/diagnostics.rs @@ -14,14 +14,14 @@ use rustc_hash::FxHashMap; use ruff_diagnostics::Diagnostic; use ruff_linter::codes::Rule; -use ruff_linter::linter::{lint_fix, lint_only, FixTable, FixerResult, LinterResult, ParseSource}; +use ruff_linter::linter::{FixTable, FixerResult, LinterResult, ParseSource, lint_fix, lint_only}; use ruff_linter::message::Message; use ruff_linter::package::PackageRoot; use ruff_linter::pyproject_toml::lint_pyproject_toml; use ruff_linter::settings::types::UnsafeFixes; -use ruff_linter::settings::{flags, LinterSettings}; +use ruff_linter::settings::{LinterSettings, flags}; use ruff_linter::source_kind::{SourceError, SourceKind}; -use ruff_linter::{fs, IOError}; +use ruff_linter::{IOError, fs}; use ruff_notebook::{Notebook, NotebookError, NotebookIndex}; use ruff_python_ast::{PySourceType, SourceType, TomlSourceType}; use ruff_source_file::SourceFileBuilder; diff --git a/crates/ruff/src/lib.rs b/crates/ruff/src/lib.rs index 11c7ba3e70..ef8f639746 100644 --- a/crates/ruff/src/lib.rs +++ b/crates/ruff/src/lib.rs @@ -1,7 +1,7 @@ #![allow(clippy::print_stdout)] use std::fs::File; -use std::io::{self, stdout, BufWriter, Write}; +use std::io::{self, BufWriter, Write, stdout}; use std::num::NonZeroUsize; use std::path::{Path, PathBuf}; use std::process::ExitCode; @@ -11,10 +11,10 @@ use anyhow::Result; use clap::CommandFactory; use colored::Colorize; use log::warn; -use notify::{recommended_watcher, RecursiveMode, Watcher}; +use notify::{RecursiveMode, Watcher, recommended_watcher}; use args::{GlobalConfigArgs, ServerCommand}; -use ruff_linter::logging::{set_up_logging, LogLevel}; +use ruff_linter::logging::{LogLevel, set_up_logging}; use ruff_linter::settings::flags::FixMode; use ruff_linter::settings::types::OutputFormat; use ruff_linter::{fs, warn_user, warn_user_once}; @@ -488,7 +488,7 @@ pub fn check(args: CheckCommand, global_options: GlobalConfigArgs) -> Result