Add exclude support to ruff analyze (#13425)

## Summary

Closes https://github.com/astral-sh/ruff/issues/13424.
This commit is contained in:
Charlie Marsh 2024-09-20 15:34:35 -04:00 committed by GitHub
parent 149fb2090e
commit 910fac781d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 108 additions and 9 deletions

View file

@ -23,10 +23,10 @@ pub struct ModuleImports(BTreeSet<SystemPathBuf>);
impl ModuleImports {
/// Detect the [`ModuleImports`] for a given Python file.
pub fn detect(
db: &ModuleDb,
path: &SystemPath,
package: Option<&SystemPath>,
string_imports: bool,
db: &ModuleDb,
) -> Result<Self> {
// Read and parse the source code.
let file = system_path_to_file(db, path)?;

View file

@ -1,5 +1,5 @@
use ruff_linter::display_settings;
use ruff_linter::settings::types::{ExtensionMapping, PreviewMode};
use ruff_linter::settings::types::{ExtensionMapping, FilePatternSet, PreviewMode};
use ruff_macros::CacheKey;
use std::collections::BTreeMap;
use std::fmt;
@ -7,6 +7,7 @@ use std::path::PathBuf;
#[derive(Debug, Default, Clone, CacheKey)]
pub struct AnalyzeSettings {
pub exclude: FilePatternSet,
pub preview: PreviewMode,
pub detect_string_imports: bool,
pub include_dependencies: BTreeMap<PathBuf, (PathBuf, Vec<String>)>,
@ -20,6 +21,7 @@ impl fmt::Display for AnalyzeSettings {
formatter = f,
namespace = "analyze",
fields = [
self.exclude,
self.preview,
self.detect_string_imports,
self.extension | debug,