mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 18:58:04 +00:00
[ty] Tell the user why we inferred a certain Python version when reporting version-specific syntax errors (#18295)
This commit is contained in:
parent
0a11baf29c
commit
6453ac9ea1
9 changed files with 201 additions and 107 deletions
|
@ -23,8 +23,8 @@ use std::sync::Arc;
|
|||
use thiserror::Error;
|
||||
use tracing::error;
|
||||
use ty_python_semantic::lint::{LintRegistry, LintRegistryBuilder, RuleSelection};
|
||||
use ty_python_semantic::register_lints;
|
||||
use ty_python_semantic::types::check_types;
|
||||
use ty_python_semantic::{add_inferred_python_version_hint_to_diagnostic, register_lints};
|
||||
|
||||
pub mod combine;
|
||||
|
||||
|
@ -460,12 +460,11 @@ fn check_file_impl(db: &dyn Db, file: File) -> Vec<Diagnostic> {
|
|||
.map(|error| create_parse_diagnostic(file, error)),
|
||||
);
|
||||
|
||||
diagnostics.extend(
|
||||
parsed
|
||||
.unsupported_syntax_errors()
|
||||
.iter()
|
||||
.map(|error| create_unsupported_syntax_diagnostic(file, error)),
|
||||
);
|
||||
diagnostics.extend(parsed.unsupported_syntax_errors().iter().map(|error| {
|
||||
let mut error = create_unsupported_syntax_diagnostic(file, error);
|
||||
add_inferred_python_version_hint_to_diagnostic(db.upcast(), &mut error, "parsing syntax");
|
||||
error
|
||||
}));
|
||||
|
||||
{
|
||||
let db = AssertUnwindSafe(db);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue