Merged
Conversation
Member
Author
|
Current dependencies on/for this PR:
This comment was auto-generated by Graphite. |
fddf952 to
24f81ef
Compare
MichaReiser
commented
May 4, 2023
| match kind { | ||
| TokenKind::Lpar | TokenKind::Lambda => parens += 1, | ||
| TokenKind::Rpar => parens -= 1, | ||
| TokenKind::Rpar => parens = parens.saturating_sub(1), |
Member
Author
There was a problem hiding this comment.
Don't panic if there are unbalanced parens.
Contributor
PR Check ResultsEcosystem✅ ecosystem check detected no changes. BenchmarkLinuxWindows |
charliermarsh
approved these changes
May 4, 2023
MichaReiser
pushed a commit
that referenced
this pull request
Jul 27, 2023
Fix nightly clippy warnings
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

This PR refactors the pycodestyle missing whitespace around operator rule and fixes a few bug where our implementation didn't match the behavior of the pycodestyle rule. My main motivation for the refactor was that I simply didn't understood the rule and failed to set the right diagnostic ranges in #4113. I find the new logic easier to understand because it only uses token specific state, but some may disagree with that.
The rule itself isn't too complicated: It ensures that operators have consistent leading and trailing spaces (an operator either has leading and trailing spaces or not) and enforces mandatory spaces around some operators.
The misunderstanding that I had for a long time is that we would want to use the Modulo diagnostic whenever some spacing with the
%operator is off (and the same for bitwise operations and arithmetic operations). But that's not the case. The logic is:MissingWhitespaceAroundOperatorif the leading and trailing spaces are not consistent regardless of the operatorMissingWhitespaceAroundAritmeticOperator,MissingWhitespaceAroundBitwiseOrShiftOperator, orMissingWhitespaceAroundModuloOperatorif the operator has no spacing and the operator is an arithmetic operator, a bitwise or shift operator, or the modulo operator (enforce spaces).MissingWhitespaceAroundOperatorotherwise.That means the logic is staged: first test for consistent spacing, and only then enforce missing whitespace with the operator-specific violation.