-
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
Fix E231
bug: Inconsistent catch compared to pycodestyle, such as when dict nested in list
#10469
Conversation
f446cd4
to
2837639
Compare
|
2837639
to
6e779de
Compare
crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/missing_whitespace.rs
Outdated
Show resolved
Hide resolved
...ter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E231_E23.py.snap
Show resolved
Hide resolved
Thanks for looking into this. Using a stack here makes sense. I'm surprised that this isn't hitting performance more, considering that we're now allocating a new |
Ya it's surprising. But is allocating a new |
dbdb4c5
to
37d2270
Compare
Took inspiration from |
That's correct: Creating an empty
Nice, thank you |
@@ -97,7 +97,7 @@ pub(crate) fn missing_whitespace(line: &LogicalLine, context: &mut LogicalLinesC | |||
if let Some(next_token) = iter.peek() { | |||
match (kind, next_token.kind()) { | |||
(TokenKind::Colon, _) | |||
if open_parentheses > 0 && prev_lsqb > prev_lbrace => | |||
if matches!(brackets.last(), Some(TokenKind::Lsqb)) => |
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.
I find this much easier to understand. Nice refactor
Summary
Fix
E231
bug: Inconsistent catch compared to pycodestyle, such as when dict nested in list. Resolves #10113.Test Plan
Example from #10113 added to test fixture.