-
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
Add message to Fix
constructor
#4276
Comments
Feel free to assign me to this one |
I've started work on this at main...madkinsz:ruff:internal/4276 and I could use a bit more context on the plan for replacing For example, there's a fix message generated at https://github.com/charliermarsh/ruff/blob/c10a4535b9549d8dab6dec024ce3231b74bf5e18/crates/ruff/src/rules/pyflakes/rules/imports.rs#L47-L54 Is the plan to duplicate that logic and generate a message at https://github.com/charliermarsh/ruff/blob/0a68636de33b3398c61cac2bead42101fcb6022e/crates/ruff/src/checkers/ast/mod.rs#L5329-L5332 For the following todo
Did you mean to say that the other way around? We should show the new For including the message in the JSON emitter, we're already showing the diagnostic kind suggestion and it seems like it would be duplicative to include both messages. We should just show one with the same logic we decide on above, right? Some additional notes...Should update this TODO https://github.com/charliermarsh/ruff/blob/a2b8487ae3c3efa99deb21376dcd504a81276a3f/crates/ruff_diagnostics/src/violation.rs#L33-L34 Autofix title is populated as the diagnostic kind suggestion at https://github.com/charliermarsh/ruff/blob/c10a4535b9549d8dab6dec024ce3231b74bf5e18/crates/ruff_macros/src/violation.rs#L62 |
Thanks and sorry that the issue is a bit less clear. I must admit, I haven't fully figured out the details myself yet and it will probably require some exploration.
My idea is to remove the There may be a few use cases where we have to duplicate the logic or use a different phrasing. This is mainly for diagnostics with
No, that's the order I had in mind. The
I'm fine with duplicating the information for now. Ultimately, the fields will store different messages. |
Thanks for your long comment and apologies for the slow reply. I've had a busy couple of weeks ;) I've made some additional progress over at main...madkinsz:ruff:internal/4276 It seems unlikely that I'll make significant progress on this in the near future — if you want it sooner rather than later feel free to pick up where I left off. Otherwise I can take this up with gusto in July. |
@madkinsz thanks for the update and no worries. We can easily wait till July, except if there's someone else interested in picking this up before then. |
I'll close this. I think it's best to reconsider this if we plan to change our fix infrastructure. The one we have right now seems to be working reasonably well. |
Depends on #4183
Add a, for now, optional
title
ormessage
field toFix
that will be used to replace theDiagnosticKind::autofix_title
.The motivation is that a diagnostic can have multiple potential fixes. For example, the unused variable diagnostic can recommend to either:
Adding the title to the
Fix
instead of specifying it on theDiagnosticKind
will allow us to model the different diagnostics.It also has the advantage that the Rust compiler can enforce the requirement that each fixable
DiagnosticKind
has a message, because it is not stored as part of theFix
.Tasks
title
ormessage
field toFix
(Option<String>
).message: String
as first argument, except forunspecified*
, to avoid having to refactor all calls at oncetitle
/message
as part of theFix
in the JSON EmitterMessageCodeFrame
implementation to showDiagnosticKind::suggestion
if present, or fall back toFix::title
if theDiagnostic
has oneFix
.The text was updated successfully, but these errors were encountered: