Skip to content

Commit ff9406a

Browse files
Merge branch 'main' into builtins-options
2 parents 56895d5 + 0a75a1d commit ff9406a

File tree

69 files changed

+6525
-2571
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+6525
-2571
lines changed

.github/workflows/ci.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ jobs:
712712
just test
713713
714714
benchmarks:
715-
runs-on: ubuntu-22.04
715+
runs-on: ubuntu-24.04
716716
needs: determine_changes
717717
if: ${{ github.repository == 'astral-sh/ruff' && !contains(github.event.pull_request.labels.*.name, 'no-test') && (needs.determine_changes.outputs.code == 'true' || github.ref == 'refs/heads/main') }}
718718
timeout-minutes: 20

Cargo.lock

-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/red_knot/src/main.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use red_knot_project::watch::ProjectWatcher;
1515
use red_knot_project::{watch, Db};
1616
use red_knot_project::{ProjectDatabase, ProjectMetadata};
1717
use red_knot_server::run_server;
18-
use ruff_db::diagnostic::{Diagnostic, Severity};
18+
use ruff_db::diagnostic::{Diagnostic, DisplayDiagnosticConfig, Severity};
1919
use ruff_db::system::{OsSystem, System, SystemPath, SystemPathBuf};
2020
use salsa::plumbing::ZalsaDatabase;
2121

@@ -231,6 +231,9 @@ impl MainLoop {
231231
result,
232232
revision: check_revision,
233233
} => {
234+
let display_config = DisplayDiagnosticConfig::default()
235+
.color(colored::control::SHOULD_COLORIZE.should_colorize());
236+
234237
let min_error_severity =
235238
if db.project().settings(db).terminal().error_on_warning {
236239
Severity::Warning
@@ -245,7 +248,7 @@ impl MainLoop {
245248
if check_revision == revision {
246249
#[allow(clippy::print_stdout)]
247250
for diagnostic in result {
248-
println!("{}", diagnostic.display(db));
251+
println!("{}", diagnostic.display(db, &display_config));
249252
}
250253
} else {
251254
tracing::debug!(

crates/red_knot_project/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ anyhow = { workspace = true }
2424
crossbeam = { workspace = true }
2525
glob = { workspace = true }
2626
notify = { workspace = true }
27-
pep440_rs = { workspace = true }
27+
pep440_rs = { workspace = true, features = ["version-ranges"] }
2828
rayon = { workspace = true }
2929
rustc-hash = { workspace = true }
3030
salsa = { workspace = true }

crates/red_knot_project/src/lib.rs

+10-9
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@ pub use metadata::{ProjectDiscoveryError, ProjectMetadata};
88
use red_knot_python_semantic::lint::{LintRegistry, LintRegistryBuilder, RuleSelection};
99
use red_knot_python_semantic::register_lints;
1010
use red_knot_python_semantic::types::check_types;
11-
use ruff_db::diagnostic::{Diagnostic, DiagnosticId, ParseDiagnostic, Severity};
11+
use ruff_db::diagnostic::{Diagnostic, DiagnosticId, ParseDiagnostic, Severity, Span};
1212
use ruff_db::files::{system_path_to_file, File};
1313
use ruff_db::parsed::parsed_module;
1414
use ruff_db::source::{source_text, SourceTextError};
1515
use ruff_db::system::walk_directory::WalkState;
1616
use ruff_db::system::{FileType, SystemPath};
1717
use ruff_python_ast::PySourceType;
18-
use ruff_text_size::TextRange;
1918
use rustc_hash::{FxBuildHasher, FxHashSet};
2019
use salsa::Durability;
2120
use salsa::Setter;
@@ -345,7 +344,13 @@ fn check_file_impl(db: &dyn Db, file: File) -> Vec<Box<dyn Diagnostic>> {
345344
boxed
346345
}));
347346

348-
diagnostics.sort_unstable_by_key(|diagnostic| diagnostic.range().unwrap_or_default().start());
347+
diagnostics.sort_unstable_by_key(|diagnostic| {
348+
diagnostic
349+
.span()
350+
.and_then(|span| span.range())
351+
.unwrap_or_default()
352+
.start()
353+
});
349354

350355
diagnostics
351356
}
@@ -458,12 +463,8 @@ impl Diagnostic for IOErrorDiagnostic {
458463
self.error.to_string().into()
459464
}
460465

461-
fn file(&self) -> Option<File> {
462-
Some(self.file)
463-
}
464-
465-
fn range(&self) -> Option<TextRange> {
466-
None
466+
fn span(&self) -> Option<Span> {
467+
Some(Span::from(self.file))
467468
}
468469

469470
fn severity(&self) -> Severity {

0 commit comments

Comments
 (0)