-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First-pass implementation of
Display
for ruff_workspace::Settings
- A new utility macro, `display_settings`, has been created to reduce boilerplate for displaying settings fields - `Display` has been implemented on many custom types used in `ruff_workspace::Settings` - `--show-settings` now uses `Display` instead of `Debug` on `ruff_workspace::Settings` Work left to be done: - A lot of formatting for Vec<_> and HashSet<_> types has been stubbed out, using `Debug` as a fallback. There should be a way to add generic formatting support for these types as a modifier in `display_settings`. - Several complex types were also stubbed out and need proper `Display` implementations rather than falling back on `Debug` - An open question needs to be answered: should this output be valid TOML? How important is that?
- Loading branch information
1 parent
79f4abb
commit 651c1aa
Showing
35 changed files
with
869 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,23 @@ | ||
//! Settings for the `flake8-bugbear` plugin. | ||
use crate::display_settings; | ||
use ruff_macros::CacheKey; | ||
use std::fmt::{Display, Formatter}; | ||
|
||
#[derive(Debug, Default, CacheKey)] | ||
pub struct Settings { | ||
pub extend_immutable_calls: Vec<String>, | ||
} | ||
|
||
impl Display for Settings { | ||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { | ||
display_settings! { | ||
formatter = f, | ||
namespace = "linter.flake8_bugbear.", | ||
fields = [ | ||
self.extend_immutable_calls | debug | ||
] | ||
} | ||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,23 @@ | ||
//! Settings for the `flake8-builtins` plugin. | ||
use crate::display_settings; | ||
use ruff_macros::CacheKey; | ||
use std::fmt::{Display, Formatter}; | ||
|
||
#[derive(Debug, Default, CacheKey)] | ||
pub struct Settings { | ||
pub builtins_ignorelist: Vec<String>, | ||
} | ||
|
||
impl Display for Settings { | ||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { | ||
display_settings! { | ||
formatter = f, | ||
namespace = "linter.flake8_builtins.", | ||
fields = [ | ||
self.builtins_ignorelist | debug | ||
] | ||
} | ||
Ok(()) | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
crates/ruff_linter/src/rules/flake8_comprehensions/settings.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,23 @@ | ||
//! Settings for the `flake8-comprehensions` plugin. | ||
use crate::display_settings; | ||
use ruff_macros::CacheKey; | ||
use std::fmt::{Display, Formatter}; | ||
|
||
#[derive(Debug, Default, CacheKey)] | ||
pub struct Settings { | ||
pub allow_dict_calls_with_keyword_arguments: bool, | ||
} | ||
|
||
impl Display for Settings { | ||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { | ||
display_settings! { | ||
formatter = f, | ||
namespace = "linter.flake8_comprehensions.", | ||
fields = [ | ||
self.allow_dict_calls_with_keyword_arguments | ||
] | ||
} | ||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,23 @@ | ||
//! Settings for the `flake8-errmsg` plugin. | ||
use crate::display_settings; | ||
use ruff_macros::CacheKey; | ||
use std::fmt::{Display, Formatter}; | ||
|
||
#[derive(Debug, Default, CacheKey)] | ||
pub struct Settings { | ||
pub max_string_length: usize, | ||
} | ||
|
||
impl Display for Settings { | ||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { | ||
display_settings! { | ||
formatter = f, | ||
namespace = "linter.flake8_errmsg.", | ||
fields = [ | ||
self.max_string_length | ||
] | ||
} | ||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.