mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-02 14:52:01 +00:00
[ty] Move respect-ignore-files
under src
section (#18322)
This commit is contained in:
parent
4e68dd96a6
commit
62ef96f51e
6 changed files with 57 additions and 50 deletions
|
@ -57,19 +57,6 @@ pub struct Options {
|
|||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[option_group]
|
||||
pub terminal: Option<TerminalOptions>,
|
||||
|
||||
/// Whether to automatically exclude files that are ignored by `.ignore`,
|
||||
/// `.gitignore`, `.git/info/exclude`, and global `gitignore` files.
|
||||
/// Enabled by default.
|
||||
#[option(
|
||||
default = r#"true"#,
|
||||
value_type = r#"bool"#,
|
||||
example = r#"
|
||||
respect-ignore-files = false
|
||||
"#
|
||||
)]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub respect_ignore_files: Option<bool>,
|
||||
}
|
||||
|
||||
impl Options {
|
||||
|
@ -216,7 +203,7 @@ impl Options {
|
|||
pub(crate) fn to_settings(&self, db: &dyn Db) -> (Settings, Vec<OptionDiagnostic>) {
|
||||
let (rules, diagnostics) = self.to_rule_selection(db);
|
||||
|
||||
let mut settings = Settings::new(rules, self.respect_ignore_files);
|
||||
let mut settings = Settings::new(rules, self.src.as_ref());
|
||||
|
||||
if let Some(terminal) = self.terminal.as_ref() {
|
||||
settings.set_terminal(TerminalSettings {
|
||||
|
@ -421,6 +408,19 @@ pub struct SrcOptions {
|
|||
"#
|
||||
)]
|
||||
pub root: Option<RelativePathBuf>,
|
||||
|
||||
/// Whether to automatically exclude files that are ignored by `.ignore`,
|
||||
/// `.gitignore`, `.git/info/exclude`, and global `gitignore` files.
|
||||
/// Enabled by default.
|
||||
#[option(
|
||||
default = r#"true"#,
|
||||
value_type = r#"bool"#,
|
||||
example = r#"
|
||||
respect-ignore-files = false
|
||||
"#
|
||||
)]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub respect_ignore_files: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Clone, Eq, PartialEq, Combine, Serialize, Deserialize)]
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use crate::metadata::options::SrcOptions;
|
||||
use ruff_db::diagnostic::DiagnosticFormat;
|
||||
use ty_python_semantic::lint::RuleSelection;
|
||||
|
||||
|
@ -26,11 +27,15 @@ pub struct Settings {
|
|||
}
|
||||
|
||||
impl Settings {
|
||||
pub fn new(rules: RuleSelection, respect_ignore_files: Option<bool>) -> Self {
|
||||
pub fn new(rules: RuleSelection, src_options: Option<&SrcOptions>) -> Self {
|
||||
let respect_ignore_files = src_options
|
||||
.and_then(|src| src.respect_ignore_files)
|
||||
.unwrap_or(true);
|
||||
|
||||
Self {
|
||||
rules: Arc::new(rules),
|
||||
terminal: TerminalSettings::default(),
|
||||
respect_ignore_files: respect_ignore_files.unwrap_or(true),
|
||||
respect_ignore_files,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue