forked from astral-sh/ruff
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
derive-msg-formats 1/5: Remove unnecessary usages of Rule::kind
This commit series removes the following associated function from the Violation trait: fn placeholder() -> Self; ruff previously used this placeholder approach for the messages it listed in the README and displayed when invoked with --explain <code>. This approach is suboptimal for three reasons: 1. The placeholder implementations are completely boring code since they just initialize the struct with some dummy values. 2. Displaying concrete error messages with arbitrary interpolated values can be confusing for the user since they might not recognize that the values are interpolated. 3. Some violations have varying format strings depending on the violation which could not be documented with the previous approach (while we could have changed the signature to return Vec<Self> this would still very much suffer from astral-sh#2 and astral-sh#3). We therefore drop Violation::placeholder in favor of a new macro-based approach, explaind in commit 4/5. Violation::placeholder is only invoked via Rule::kind, so we firstly have to get rid of all Rule::kind invocations ... this commit starts removing the trivial cases.
- Loading branch information
1 parent
6af31cd
commit 8da817c
Showing
4 changed files
with
90 additions
and
100 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