mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-30 22:01:47 +00:00
Add per-file-target-version
option (#16257)
## Summary
This PR is another step in preparing to detect syntax errors in the
parser. It introduces the new `per-file-target-version` top-level
configuration option, which holds a mapping of compiled glob patterns to
Python versions. I intend to use the
`LinterSettings::resolve_target_version` method here to pass to the
parser:
f50849aeef/crates/ruff_linter/src/linter.rs (L491-L493)
## Test Plan
I added two new CLI tests to show that the `per-file-target-version` is
respected in both the formatter and the linter.
This commit is contained in:
parent
42a5f5ef6a
commit
e7a6c19e3a
78 changed files with 820 additions and 274 deletions
|
@ -104,6 +104,8 @@ pub fn check_path(
|
|||
));
|
||||
}
|
||||
|
||||
let target_version = settings.resolve_target_version(path);
|
||||
|
||||
// Run the filesystem-based rules.
|
||||
if settings
|
||||
.rules
|
||||
|
@ -116,6 +118,7 @@ pub fn check_path(
|
|||
locator,
|
||||
comment_ranges,
|
||||
settings,
|
||||
target_version,
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -158,6 +161,7 @@ pub fn check_path(
|
|||
source_type,
|
||||
cell_offsets,
|
||||
notebook_index,
|
||||
target_version,
|
||||
));
|
||||
}
|
||||
if use_imports {
|
||||
|
@ -171,6 +175,7 @@ pub fn check_path(
|
|||
package,
|
||||
source_type,
|
||||
cell_offsets,
|
||||
target_version,
|
||||
);
|
||||
|
||||
diagnostics.extend(import_diagnostics);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue