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

@ -3320,6 +3320,27 @@ pub struct FormatOptions {
#[serde(deny_unknown_fields, rename_all = "kebab-case")]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct AnalyzeOptions {
/// A list of file patterns to exclude from analysis in addition to the files excluded globally (see [`exclude`](#exclude), and [`extend-exclude`](#extend-exclude)).
///
/// Exclusions are based on globs, and can be either:
///
/// - Single-path patterns, like `.mypy_cache` (to exclude any directory
/// named `.mypy_cache` in the tree), `foo.py` (to exclude any file named
/// `foo.py`), or `foo_*.py` (to exclude any file matching `foo_*.py` ).
/// - Relative patterns, like `directory/foo.py` (to exclude that specific
/// file) or `directory/*.py` (to exclude any Python files in
/// `directory`). Note that these paths are relative to the project root
/// (e.g., the directory containing your `pyproject.toml`).
///
/// For more information on the glob syntax, refer to the [`globset` documentation](https://docs.rs/globset/latest/globset/#syntax).
#[option(
default = r#"[]"#,
value_type = "list[str]",
example = r#"
exclude = ["generated"]
"#
)]
pub exclude: Option<Vec<String>>,
/// Whether to enable preview mode. When preview mode is enabled, Ruff will expose unstable
/// commands.
#[option(