Skip to content

Commit

Permalink
fix: do not trigger E225 and E275 when the next token is a ')'
Browse files Browse the repository at this point in the history
Fixes #10295.
  • Loading branch information
hoel-bagard committed Mar 9, 2024
1 parent 0c84fbb commit f9ffa80
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ pub(crate) fn missing_whitespace_after_keyword(
|| tok0_kind == TokenKind::Yield && tok1_kind == TokenKind::Rpar
|| matches!(
tok1_kind,
TokenKind::Colon | TokenKind::Newline | TokenKind::NonLogicalNewline
TokenKind::Colon
| TokenKind::Newline
| TokenKind::NonLogicalNewline
| TokenKind::Rpar // In case of a syntax error, do not attempt to add a whitespace.
))
&& tok0.end() == tok1.start()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,13 @@ pub(crate) fn missing_whitespace_around_operator(
while let Some(token) = tokens.next() {
let kind = token.kind();

if kind.is_trivia() {
// There should not be a ")" directly after a token, as it is a syntax error. However if that happens,
// allow it in order to prevent entering a loop where E225 adds a space only for E202 to remove it.
if kind.is_trivia()
|| tokens
.peek()
.is_some_and(|token| token.kind() == TokenKind::Rpar)
{
continue;
}

Expand Down

0 comments on commit f9ffa80

Please sign in to comment.