-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Deduplicate deprecation warnings for v0.2.0 release #9764
Conversation
@@ -1447,8 +1453,9 @@ fn warn_about_deprecated_top_level_lint_options(top_level_options: &LintCommonOp | |||
.map(|option| format!("- '{option}' -> 'lint.{option}'")) | |||
.join("\n "); | |||
|
|||
warn_user!( | |||
"The top-level linter settings are deprecated in favour of their counterparts in the `lint` section. Please update the following options in your configuration:\n {options_mapping}\n\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The two trailing newlines at the end here looked odd to me in practice.
45cc8aa
to
bf532d7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great - just one small suggestion about naming.
@@ -34,6 +35,26 @@ macro_rules! warn_user_once_by_id { | |||
}; | |||
} | |||
|
|||
pub static MESSAGES: Lazy<Mutex<FxHashSet<String>>> = Lazy::new(Mutex::default); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A small nit for clarity.
pub static MESSAGES: Lazy<Mutex<FxHashSet<String>>> = Lazy::new(Mutex::default); | |
pub static PREVIOUS_MESSAGES: Lazy<Mutex<FxHashSet<String>>> = Lazy::new(Mutex::default); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yee we really needed this
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks 🤩
warn_about_deprecated_top_level_lint_options(&options.lint_top_level.0); | ||
/// Convert the [`Options`] read from the given [`Path`] into a [`Configuration`]. | ||
pub fn from_options(options: Options, path: &Path, project_root: &Path) -> Result<Self> { | ||
warn_about_deprecated_top_level_lint_options(&options.lint_top_level.0, path); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we know why we call this method twice for every configuration ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Presumedly because we call it once at the very start of Ruff to find the "default configuration", and then once when we visited it as part of the directory of files we're analyzing. (We should fix that -- it's not "incorrect" but it is inefficient.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...and we didn't catch this in the tests because we pass --config which bypasses the discovery
Summary
Adds an additional warning macro (we should consolidate these later) that shows a warning once based on the content of the warning itself. This is less efficient than
warn_user_once!
andwarn_user_by_id!
, but this is so expensive that it doesn't matter at all.Applies this macro to the various warnings for the v0.2.0 release, and also includes the filename in said warnings, so the FastAPI case is now: