mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-30 05:44:56 +00:00
[ty] File inclusion and exclusion (#18498)
This commit is contained in:
parent
3c6c017950
commit
1f27d53fd5
23 changed files with 2728 additions and 159 deletions
|
@ -5,7 +5,9 @@ use clap::{ArgAction, ArgMatches, Error, Parser};
|
|||
use ruff_db::system::SystemPathBuf;
|
||||
use ty_project::combine::Combine;
|
||||
use ty_project::metadata::options::{EnvironmentOptions, Options, SrcOptions, TerminalOptions};
|
||||
use ty_project::metadata::value::{RangedValue, RelativePathBuf, ValueSource};
|
||||
use ty_project::metadata::value::{
|
||||
RangedValue, RelativeExcludePattern, RelativePathBuf, ValueSource,
|
||||
};
|
||||
use ty_python_semantic::lint;
|
||||
|
||||
#[derive(Debug, Parser)]
|
||||
|
@ -148,6 +150,13 @@ pub(crate) struct CheckCommand {
|
|||
respect_ignore_files: Option<bool>,
|
||||
#[clap(long, overrides_with("respect_ignore_files"), hide = true)]
|
||||
no_respect_ignore_files: bool,
|
||||
|
||||
/// Glob patterns for files to exclude from type checking.
|
||||
///
|
||||
/// Uses gitignore-style syntax to exclude files and directories from type checking.
|
||||
/// Supports patterns like `tests/`, `*.tmp`, `**/__pycache__/**`.
|
||||
#[arg(long, help_heading = "File selection")]
|
||||
exclude: Option<Vec<String>>,
|
||||
}
|
||||
|
||||
impl CheckCommand {
|
||||
|
@ -195,6 +204,12 @@ impl CheckCommand {
|
|||
}),
|
||||
src: Some(SrcOptions {
|
||||
respect_ignore_files,
|
||||
exclude: self.exclude.map(|excludes| {
|
||||
excludes
|
||||
.iter()
|
||||
.map(|exclude| RelativeExcludePattern::cli(exclude))
|
||||
.collect()
|
||||
}),
|
||||
..SrcOptions::default()
|
||||
}),
|
||||
rules,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue