mirror of
https://github.com/astral-sh/ruff
synced 2026-01-20 21:10:48 -05:00
Implement a --show-source setting (#698)
This commit is contained in:
committed by
GitHub
parent
49559da54e
commit
e81efa5a3d
@@ -31,6 +31,7 @@ pub struct Configuration {
|
||||
pub select: Vec<CheckCodePrefix>,
|
||||
pub src: Vec<PathBuf>,
|
||||
pub target_version: PythonVersion,
|
||||
pub show_source: bool,
|
||||
// Plugins
|
||||
pub flake8_annotations: flake8_annotations::settings::Settings,
|
||||
pub flake8_bugbear: flake8_bugbear::settings::Settings,
|
||||
@@ -134,6 +135,7 @@ impl Configuration {
|
||||
.collect()
|
||||
})
|
||||
.unwrap_or_default(),
|
||||
show_source: options.show_source.unwrap_or_default(),
|
||||
// Plugins
|
||||
flake8_annotations: options
|
||||
.flake8_annotations
|
||||
|
||||
@@ -34,6 +34,7 @@ pub struct Settings {
|
||||
pub per_file_ignores: Vec<PerFileIgnore>,
|
||||
pub src: Vec<PathBuf>,
|
||||
pub target_version: PythonVersion,
|
||||
pub show_source: bool,
|
||||
// Plugins
|
||||
pub flake8_annotations: flake8_annotations::settings::Settings,
|
||||
pub flake8_bugbear: flake8_bugbear::settings::Settings,
|
||||
@@ -67,6 +68,7 @@ impl Settings {
|
||||
per_file_ignores: config.per_file_ignores,
|
||||
src: config.src,
|
||||
target_version: config.target_version,
|
||||
show_source: config.show_source,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,6 +89,7 @@ impl Settings {
|
||||
isort: Default::default(),
|
||||
mccabe: Default::default(),
|
||||
pep8_naming: Default::default(),
|
||||
show_source: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,6 +110,7 @@ impl Settings {
|
||||
isort: Default::default(),
|
||||
mccabe: Default::default(),
|
||||
pep8_naming: Default::default(),
|
||||
show_source: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -122,6 +126,7 @@ impl Hash for Settings {
|
||||
for value in self.per_file_ignores.iter() {
|
||||
value.hash(state);
|
||||
}
|
||||
self.show_source.hash(state);
|
||||
self.target_version.hash(state);
|
||||
// Add plugin properties in alphabetical order.
|
||||
self.flake8_annotations.hash(state);
|
||||
|
||||
@@ -24,6 +24,7 @@ pub struct Options {
|
||||
pub select: Option<Vec<CheckCodePrefix>>,
|
||||
pub src: Option<Vec<String>>,
|
||||
pub target_version: Option<PythonVersion>,
|
||||
pub show_source: Option<bool>,
|
||||
// Plugins
|
||||
pub flake8_annotations: Option<flake8_annotations::settings::Options>,
|
||||
pub flake8_bugbear: Option<flake8_bugbear::settings::Options>,
|
||||
|
||||
@@ -146,6 +146,7 @@ mod tests {
|
||||
dummy_variable_rgx: None,
|
||||
src: None,
|
||||
target_version: None,
|
||||
show_source: None,
|
||||
flake8_annotations: None,
|
||||
flake8_bugbear: None,
|
||||
flake8_quotes: None,
|
||||
@@ -180,6 +181,7 @@ line-length = 79
|
||||
dummy_variable_rgx: None,
|
||||
src: None,
|
||||
target_version: None,
|
||||
show_source: None,
|
||||
flake8_annotations: None,
|
||||
flake8_bugbear: None,
|
||||
flake8_quotes: None,
|
||||
@@ -214,6 +216,7 @@ exclude = ["foo.py"]
|
||||
dummy_variable_rgx: None,
|
||||
src: None,
|
||||
target_version: None,
|
||||
show_source: None,
|
||||
flake8_annotations: None,
|
||||
flake8_bugbear: None,
|
||||
flake8_quotes: None,
|
||||
@@ -248,6 +251,7 @@ select = ["E501"]
|
||||
dummy_variable_rgx: None,
|
||||
src: None,
|
||||
target_version: None,
|
||||
show_source: None,
|
||||
flake8_annotations: None,
|
||||
flake8_bugbear: None,
|
||||
flake8_quotes: None,
|
||||
@@ -283,6 +287,7 @@ ignore = ["E501"]
|
||||
dummy_variable_rgx: None,
|
||||
src: None,
|
||||
target_version: None,
|
||||
show_source: None,
|
||||
flake8_annotations: None,
|
||||
flake8_bugbear: None,
|
||||
flake8_quotes: None,
|
||||
@@ -364,6 +369,7 @@ other-attribute = 1
|
||||
dummy_variable_rgx: None,
|
||||
src: None,
|
||||
target_version: None,
|
||||
show_source: None,
|
||||
flake8_annotations: None,
|
||||
flake8_bugbear: Some(flake8_bugbear::settings::Options {
|
||||
extend_immutable_calls: Some(vec![
|
||||
|
||||
@@ -49,6 +49,7 @@ pub struct UserConfiguration {
|
||||
pub select: Vec<CheckCodePrefix>,
|
||||
pub src: Vec<PathBuf>,
|
||||
pub target_version: PythonVersion,
|
||||
pub show_source: bool,
|
||||
// Plugins
|
||||
pub flake8_annotations: flake8_annotations::settings::Settings,
|
||||
pub flake8_quotes: flake8_quotes::settings::Settings,
|
||||
@@ -96,6 +97,7 @@ impl UserConfiguration {
|
||||
select: configuration.select,
|
||||
src: configuration.src,
|
||||
target_version: configuration.target_version,
|
||||
show_source: configuration.show_source,
|
||||
flake8_annotations: configuration.flake8_annotations,
|
||||
flake8_quotes: configuration.flake8_quotes,
|
||||
flake8_tidy_imports: configuration.flake8_tidy_imports,
|
||||
|
||||
Reference in New Issue
Block a user