Add [format|lint].exclude options (#8000)

This commit is contained in:
Micha Reiser 2023-10-18 10:15:25 +09:00 committed by GitHub
parent d685107638
commit fe485d791c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 772 additions and 294 deletions

View file

@ -4,7 +4,7 @@ use anyhow::Result;
use ruff_linter::packaging;
use ruff_linter::settings::flags;
use ruff_workspace::resolver::{python_file_at_path, PyprojectConfig};
use ruff_workspace::resolver::{match_exclusion, python_file_at_path, PyprojectConfig};
use crate::args::CliOverrides;
use crate::diagnostics::{lint_stdin, Diagnostics};
@ -22,6 +22,14 @@ pub(crate) fn check_stdin(
if !python_file_at_path(filename, pyproject_config, overrides)? {
return Ok(Diagnostics::default());
}
let lint_settings = &pyproject_config.settings.linter;
if filename
.file_name()
.is_some_and(|name| match_exclusion(filename, name, &lint_settings.exclude))
{
return Ok(Diagnostics::default());
}
}
let package_root = filename.and_then(Path::parent).and_then(|path| {
packaging::detect_package_root(path, &pyproject_config.settings.linter.namespace_packages)