Skip to content

Commit

Permalink
Move show_source onto CLI settings group (#4316)
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh authored May 9, 2023
1 parent 139f778 commit 435489f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
1 change: 0 additions & 1 deletion crates/ruff/src/settings/defaults.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ impl Default for Settings {
namespace_packages: vec![],
per_file_ignores: vec![],
respect_gitignore: true,
show_source: false,
src: vec![path_dedot::CWD.clone()],
project_root: path_dedot::CWD.clone(),
target_version: TARGET_VERSION,
Expand Down
9 changes: 4 additions & 5 deletions crates/ruff/src/settings/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ impl AllSettings {
fix_only: config.fix_only.unwrap_or(false),
format: config.format.unwrap_or_default(),
show_fixes: config.show_fixes.unwrap_or(false),
show_source: config.show_source.unwrap_or(false),
},
lib: Settings::from_configuration(config, project_root)?,
})
Expand All @@ -65,14 +66,14 @@ impl AllSettings {

#[derive(Debug, Default, Clone)]
#[allow(clippy::struct_excessive_bools)]
/// Settings that are not used by this library and
/// only here so that `ruff_cli` can use them.
/// Settings that are not used by this library and only here so that `ruff_cli` can use them.
pub struct CliSettings {
pub cache_dir: PathBuf,
pub fix: bool,
pub fix_only: bool,
pub format: SerializationFormat,
pub show_fixes: bool,
pub show_source: bool,
}

#[derive(Debug, CacheKey)]
Expand All @@ -81,7 +82,6 @@ pub struct Settings {
pub rules: RuleTable,
pub per_file_ignores: Vec<(GlobMatcher, GlobMatcher, RuleSet)>,

pub show_source: bool,
pub target_version: PythonVersion,

// Resolver settings
Expand Down Expand Up @@ -168,7 +168,6 @@ impl Settings {
config.per_file_ignores.unwrap_or_default(),
)?,
respect_gitignore: config.respect_gitignore.unwrap_or(true),
show_source: config.show_source.unwrap_or_default(),
src: config
.src
.unwrap_or_else(|| vec![project_root.to_path_buf()]),
Expand Down Expand Up @@ -449,7 +448,7 @@ mod tests {
#[test]
fn rule_codes() {
let actual = resolve_rules([RuleSelection {
select: Some(vec![codes::Pycodestyle::W.into()]),
select: Some(vec![Pycodestyle::W.into()]),
..RuleSelection::default()
}]);

Expand Down
4 changes: 2 additions & 2 deletions crates/ruff_cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ fn check(args: CheckArgs, log_level: LogLevel) -> Result<ExitStatus> {
fix_only,
format,
show_fixes,
show_source,
..
} = pyproject_config.settings.cli;

Expand Down Expand Up @@ -181,8 +182,7 @@ fn check(args: CheckArgs, log_level: LogLevel) -> Result<ExitStatus> {
if show_fixes {
printer_flags |= PrinterFlags::SHOW_FIXES;
}

if pyproject_config.settings.lib.show_source {
if show_source {
printer_flags |= PrinterFlags::SHOW_SOURCE;
}

Expand Down

0 comments on commit 435489f

Please sign in to comment.