mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 18:58:04 +00:00
Make lint_only
aware of the source kind (#5876)
This commit is contained in:
parent
1181d25e5a
commit
7e6b472c5b
3 changed files with 21 additions and 3 deletions
|
@ -321,6 +321,7 @@ pub fn lint_only(
|
|||
package: Option<&Path>,
|
||||
settings: &Settings,
|
||||
noqa: flags::Noqa,
|
||||
source_kind: Option<&SourceKind>,
|
||||
) -> LinterResult<(Vec<Message>, Option<ImportMap>)> {
|
||||
// Tokenize once.
|
||||
let tokens: Vec<LexResult> = ruff_rustpython::tokenize(contents);
|
||||
|
@ -353,7 +354,7 @@ pub fn lint_only(
|
|||
&directives,
|
||||
settings,
|
||||
noqa,
|
||||
None,
|
||||
source_kind,
|
||||
);
|
||||
|
||||
result.map(|(diagnostics, imports)| {
|
||||
|
|
|
@ -63,6 +63,7 @@ fn benchmark_linter(mut group: BenchmarkGroup<WallTime>, settings: &Settings) {
|
|||
None,
|
||||
settings,
|
||||
flags::Noqa::Enabled,
|
||||
None,
|
||||
);
|
||||
|
||||
// Assert that file contains no parse errors
|
||||
|
|
|
@ -204,12 +204,26 @@ pub(crate) fn lint_path(
|
|||
(result, fixed)
|
||||
} else {
|
||||
// If we fail to autofix, lint the original source code.
|
||||
let result = lint_only(&contents, path, package, &settings.lib, noqa);
|
||||
let result = lint_only(
|
||||
&contents,
|
||||
path,
|
||||
package,
|
||||
&settings.lib,
|
||||
noqa,
|
||||
Some(&source_kind),
|
||||
);
|
||||
let fixed = FxHashMap::default();
|
||||
(result, fixed)
|
||||
}
|
||||
} else {
|
||||
let result = lint_only(&contents, path, package, &settings.lib, noqa);
|
||||
let result = lint_only(
|
||||
&contents,
|
||||
path,
|
||||
package,
|
||||
&settings.lib,
|
||||
noqa,
|
||||
Some(&source_kind),
|
||||
);
|
||||
let fixed = FxHashMap::default();
|
||||
(result, fixed)
|
||||
};
|
||||
|
@ -316,6 +330,7 @@ pub(crate) fn lint_stdin(
|
|||
package,
|
||||
settings,
|
||||
noqa,
|
||||
Some(&source_kind),
|
||||
);
|
||||
let fixed = FxHashMap::default();
|
||||
|
||||
|
@ -333,6 +348,7 @@ pub(crate) fn lint_stdin(
|
|||
package,
|
||||
settings,
|
||||
noqa,
|
||||
Some(&source_kind),
|
||||
);
|
||||
let fixed = FxHashMap::default();
|
||||
(result, fixed)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue