Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
4620604
add DiagnosticId::Unformatted
ntBre Sep 16, 2025
92208ab
add --output-format to the ruff format cli
ntBre Sep 24, 2025
041b35d
allow tempdir_filter to take any AsRef<Path>
ntBre Sep 24, 2025
9bb4374
respect show_fix_status for `full` output
ntBre Sep 24, 2025
9cffdd8
suppress the URL for all non-lint DiagnosticIds
ntBre Sep 24, 2025
5bfe3f2
fix a couple of Rome references
ntBre Sep 24, 2025
76e63b3
add `CellOffsets::ranges` helper
ntBre Sep 22, 2025
7e48156
convert FormatPathResults to Diagnostics just before rendering
ntBre Sep 16, 2025
a5ec195
build a real notebook index and render cell diffs
ntBre Sep 24, 2025
4ea16b7
convert errors to diagnostics too
ntBre Sep 24, 2025
39f96cc
allow passing a header offset into annotate-snippets
ntBre Sep 25, 2025
a43fa93
factor out PanicError::to_diagnostic_message
ntBre Sep 25, 2025
959f55a
add error tests, set_file_level, and improve panic formatting
ntBre Sep 25, 2025
2ce8f80
use FormatResult::diff for checking, revert other changes
ntBre Sep 26, 2025
007a22f
point out preview restriction on format --output-format
ntBre Sep 26, 2025
451dc0c
emit a warning for non-preview --output-format usage
ntBre Sep 26, 2025
78fdc60
sort errors and diagnostics together
ntBre Sep 26, 2025
28ebcd5
factor out create_panic_diagnostic, reuse in the linter
ntBre Sep 26, 2025
090468d
delete TODO for ignore::Errors
ntBre Sep 26, 2025
723d1d5
use FormatError for PrintError
ntBre Sep 26, 2025
05faf43
add DisplayParseError::error and render the ParseErrorType directly
ntBre Sep 26, 2025
ed63b7e
calculate a real range for the diagnostics
ntBre Sep 26, 2025
c1a3b44
reuse FormatCommandError::Write instead of Diff
ntBre Sep 26, 2025
73eb86d
DiagnosticId::RangeFormatNotebook -> InvalidCliOption
ntBre Sep 26, 2025
aee8fd3
DiagnosticId::FormatError -> InternalError
ntBre Sep 26, 2025
0668704
add a todo about the offset hack
ntBre Sep 26, 2025
519b6fa
file_level -> hide_snippet
ntBre Sep 26, 2025
1864018
debug assert FormatResult::Diff
ntBre Sep 29, 2025
aa532d7
narrow edit range to modified lines
ntBre Sep 29, 2025
cbf7d1f
account for context lines when computing the line number width
ntBre Sep 29, 2025
7b8b442
mark FormatModuleError::InvalidSyntax as an internal error
ntBre Sep 29, 2025
57db031
Merge branch 'main' into brent/formatter-diagnostics
ntBre Sep 29, 2025
74de549
use render_diagnostics helper
ntBre Sep 29, 2025
6a72314
fix range narrowing for strict prefixes
ntBre Sep 29, 2025
793f526
range -> modified_range, restore previous range references
ntBre Sep 29, 2025
bf48b9b
only restrict the end of the script line counting
ntBre Sep 29, 2025
bedfc6f
use loop for prefix_length too, use guarded break for suffix
ntBre Sep 30, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions crates/ruff/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,14 @@ pub struct FormatCommand {
/// Exit with a non-zero status code if any files were modified via format, even if all files were formatted successfully.
#[arg(long, help_heading = "Miscellaneous", alias = "exit-non-zero-on-fix")]
pub exit_non_zero_on_format: bool,

/// Output serialization format for violations, when used with `--check`.
/// The default serialization format is "full".
///
/// Note that this option is currently only respected in preview mode. A warning will be emitted
/// if this flag is used on stable.
#[arg(long, value_enum, env = "RUFF_OUTPUT_FORMAT")]
pub output_format: Option<OutputFormat>,
}

#[derive(Copy, Clone, Debug, clap::Parser)]
Expand Down Expand Up @@ -784,6 +792,7 @@ impl FormatCommand {
target_version: self.target_version.map(ast::PythonVersion::from),
cache_dir: self.cache_dir,
extension: self.extension,
output_format: self.output_format,
..ExplicitConfigOverrides::default()
};

Expand Down
23 changes: 3 additions & 20 deletions crates/ruff/src/commands/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ use ignore::Error;
use log::{debug, warn};
#[cfg(not(target_family = "wasm"))]
use rayon::prelude::*;
use ruff_linter::message::create_panic_diagnostic;
use rustc_hash::FxHashMap;

use ruff_db::diagnostic::{
Annotation, Diagnostic, DiagnosticId, Span, SubDiagnostic, SubDiagnosticSeverity,
};
use ruff_db::diagnostic::Diagnostic;
use ruff_db::panic::catch_unwind;
use ruff_linter::package::PackageRoot;
use ruff_linter::registry::Rule;
Expand Down Expand Up @@ -195,23 +194,7 @@ fn lint_path(
match result {
Ok(inner) => inner,
Err(error) => {
let message = match error.payload.as_str() {
Some(summary) => format!("Fatal error while linting: {summary}"),
_ => "Fatal error while linting".to_owned(),
};
let mut diagnostic = Diagnostic::new(
DiagnosticId::Panic,
ruff_db::diagnostic::Severity::Fatal,
message,
);
let span = Span::from(SourceFileBuilder::new(path.to_string_lossy(), "").finish());
let mut annotation = Annotation::primary(span);
annotation.set_file_level(true);
diagnostic.annotate(annotation);
diagnostic.sub(SubDiagnostic::new(
SubDiagnosticSeverity::Info,
format!("{error}"),
));
let diagnostic = create_panic_diagnostic(&error, Some(path));
Ok(Diagnostics::new(vec![diagnostic], FxHashMap::default()))
}
}
Expand Down
Loading