Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Support extend-select in pyproject.toml #327

Merged
merged 1 commit into from
Oct 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/pyproject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ pub struct Config {
pub extend_exclude: Vec<String>,
pub select: Option<Vec<CheckCode>>,
#[serde(default)]
pub extend_select: Vec<CheckCode>,
#[serde(default)]
pub ignore: Vec<CheckCode>,
#[serde(default)]
pub per_file_ignores: Vec<StrCheckCodePair>,
Expand Down Expand Up @@ -180,6 +182,7 @@ mod tests {
exclude: None,
extend_exclude: vec![],
select: None,
extend_select: vec![],
ignore: vec![],
per_file_ignores: vec![],
dummy_variable_rgx: None,
Expand All @@ -202,6 +205,7 @@ line-length = 79
exclude: None,
extend_exclude: vec![],
select: None,
extend_select: vec![],
ignore: vec![],
per_file_ignores: vec![],
dummy_variable_rgx: None,
Expand All @@ -224,6 +228,7 @@ exclude = ["foo.py"]
exclude: Some(vec!["foo.py".to_string()]),
extend_exclude: vec![],
select: None,
extend_select: vec![],
ignore: vec![],
per_file_ignores: vec![],
dummy_variable_rgx: None,
Expand All @@ -246,6 +251,7 @@ select = ["E501"]
exclude: None,
extend_exclude: vec![],
select: Some(vec![CheckCode::E501]),
extend_select: vec![],
ignore: vec![],
per_file_ignores: vec![],
dummy_variable_rgx: None,
Expand All @@ -257,6 +263,7 @@ select = ["E501"]
r#"
[tool.black]
[tool.ruff]
extend-select = ["M001"]
ignore = ["E501"]
"#,
)?;
Expand All @@ -268,6 +275,7 @@ ignore = ["E501"]
exclude: None,
extend_exclude: vec![],
select: None,
extend_select: vec![CheckCode::M001],
ignore: vec![CheckCode::E501],
per_file_ignores: vec![],
dummy_variable_rgx: None,
Expand Down Expand Up @@ -334,6 +342,7 @@ other-attribute = 1
"directory/also_excluded.py".to_string(),
],
select: None,
extend_select: vec![],
ignore: vec![],
per_file_ignores: vec![],
dummy_variable_rgx: None,
Expand Down
1 change: 1 addition & 0 deletions src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ impl Settings {
pyproject,
project_root,
};
settings.select(config.extend_select);
settings.ignore(&config.ignore);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like the semantics here are off (but that they were off before with settings.ignore(&config.ignore) -- not any fault of your change). We should probably avoid calling settings.ignore(&config.ignore), since if the user provides a --ignore on the command-line, we'd want to respect that instead (not in addition). Same for extend_select.

But this can be changed separately, what you have here is an improvement in overall behavior.

Ok(settings)
}
Expand Down