Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

--show-settings displays active settings in a far more readable format #9464

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
651c1aa
First-pass implementation of `Display` for `ruff_workspace::Settings`
snowsignal Jan 11, 2024
1341d50
Use `Display::fmt` directly instead of `write!(f, {}, ...)`
snowsignal Jan 11, 2024
415104e
Make `namespace` an optional parameter for `display_settings` and rem…
snowsignal Jan 11, 2024
afe986c
Eliminate unnessecary allocations in the `Display` implementations of…
snowsignal Jan 11, 2024
16dbd8f
Remove unnessecary allocation from `impl Display for KnownModules` an…
snowsignal Jan 11, 2024
e7a6aab
Implement `array` and `optional` formatting options for `display_sett…
snowsignal Jan 11, 2024
eb9c1fb
Add `quoted` formatter to `display_settings` and document the `displa…
snowsignal Jan 11, 2024
0ce38bc
Properly implement `Display` for `PerFileIgnores`
snowsignal Jan 11, 2024
2856361
Merge branch 'main' of github.com:astral-sh/ruff into jane/settings/d…
snowsignal Jan 11, 2024
14221b6
Set up a snapshot test for the default output of `--show-settings`
snowsignal Jan 11, 2024
84a1a2c
Remove extraneous newline from stdout for `--show-settings`
snowsignal Jan 11, 2024
14a8a6e
Cleanup snapshot tests
snowsignal Jan 11, 2024
8c82e87
Add top-level comment to `Settings` display
snowsignal Jan 12, 2024
5793b60
Make `resolve_per_file_ignores` into an associated function
snowsignal Jan 12, 2024
142883c
Space out comment headers for settings display
snowsignal Jan 12, 2024
b3e3c39
Add Linter Plugins heading to settings display
snowsignal Jan 12, 2024
27007a1
Use 'none' instead of 'nil' when displaying None values in settings
snowsignal Jan 12, 2024
ba3e00b
Explain the order of matchers in `PerFileIgnores`
snowsignal Jan 12, 2024
a24a50a
Merge branch 'main' of github.com:astral-sh/ruff into jane/settings/d…
snowsignal Jan 12, 2024
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
2 changes: 1 addition & 1 deletion crates/ruff_cli/src/commands/show_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub(crate) fn show_settings(
if let Some(settings_path) = pyproject_config.path.as_ref() {
writeln!(writer, "Settings path: {settings_path:?}")?;
}
writeln!(writer, "{settings:#?}")?;
write!(writer, "{settings}")?;

Ok(())
}
29 changes: 29 additions & 0 deletions crates/ruff_cli/tests/show_settings.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
use insta_cmd::{assert_cmd_snapshot, get_cargo_bin};
use std::path::Path;
use std::process::Command;

const BIN_NAME: &str = "ruff";

#[cfg(not(target_os = "windows"))]
const TEST_FILTERS: &[(&str, &str)] = &[
("\"[^\\*\"]*/pyproject.toml", "\"[BASEPATH]/pyproject.toml"),
("\".*/crates", "\"[BASEPATH]/crates"),
("\".*/\\.ruff_cache", "\"[BASEPATH]/.ruff_cache"),
("\".*/ruff\"", "\"[BASEPATH]\""),
];
#[cfg(target_os = "windows")]
const TEST_FILTERS: &[(&str, &str)] = &[
(r#""[^\*"]*\\pyproject.toml"#, "\"[BASEPATH]/pyproject.toml"),
(r#"".*\\crates"#, "\"[BASEPATH]/crates"),
(r#"".*\\\.ruff_cache"#, "\"[BASEPATH]/.ruff_cache"),
(r#"".*\\ruff""#, "\"[BASEPATH]\""),
(r#"\\+(\w\w|\s|")"#, "/$1"),
];

#[test]
fn display_default_settings() {
insta::with_settings!({ filters => TEST_FILTERS.to_vec() }, {
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
.args(["check", "--show-settings", "unformatted.py"]).current_dir(Path::new("./resources/test/fixtures")));
});
}
Loading
Loading