mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-17 07:45:36 +00:00
Add a CLI flag to force-ignore noqa directives (#3296)
This commit is contained in:
parent
4a70a4c323
commit
3ed539d50e
10 changed files with 55 additions and 15 deletions
|
@ -26,6 +26,7 @@ pub fn run(
|
|||
pyproject_strategy: &PyprojectDiscovery,
|
||||
overrides: &Overrides,
|
||||
cache: flags::Cache,
|
||||
noqa: flags::Noqa,
|
||||
autofix: fix::FixMode,
|
||||
) -> Result<Diagnostics> {
|
||||
// Collect all the Python files to check.
|
||||
|
@ -84,7 +85,7 @@ pub fn run(
|
|||
.and_then(|parent| package_roots.get(parent))
|
||||
.and_then(|package| *package);
|
||||
let settings = resolver.resolve_all(path, pyproject_strategy);
|
||||
lint_path(path, package, settings, cache, autofix)
|
||||
lint_path(path, package, settings, cache, noqa, autofix)
|
||||
.map_err(|e| (Some(path.to_owned()), e.to_string()))
|
||||
}
|
||||
Err(e) => Err((
|
||||
|
|
|
@ -4,6 +4,7 @@ use std::path::Path;
|
|||
use anyhow::Result;
|
||||
|
||||
use ruff::resolver::PyprojectDiscovery;
|
||||
use ruff::settings::flags;
|
||||
use ruff::{fix, packaging, resolver};
|
||||
|
||||
use crate::args::Overrides;
|
||||
|
@ -21,6 +22,7 @@ pub fn run_stdin(
|
|||
filename: Option<&Path>,
|
||||
pyproject_strategy: &PyprojectDiscovery,
|
||||
overrides: &Overrides,
|
||||
noqa: flags::Noqa,
|
||||
autofix: fix::FixMode,
|
||||
) -> Result<Diagnostics> {
|
||||
if let Some(filename) = filename {
|
||||
|
@ -33,7 +35,7 @@ pub fn run_stdin(
|
|||
.and_then(Path::parent)
|
||||
.and_then(|path| packaging::detect_package_root(path, &settings.lib.namespace_packages));
|
||||
let stdin = read_from_stdin()?;
|
||||
let mut diagnostics = lint_stdin(filename, package_root, &stdin, &settings.lib, autofix)?;
|
||||
let mut diagnostics = lint_stdin(filename, package_root, &stdin, &settings.lib, noqa, autofix)?;
|
||||
diagnostics.messages.sort_unstable();
|
||||
Ok(diagnostics)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue