Skip to content
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

RUF022, RUF023: never add two trailing commas to the end of a sequence #9698

Merged
merged 6 commits into from
Jan 30, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
simplify
  • Loading branch information
AlexWaygood committed Jan 30, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 5082eb88eec8dea5570250aaa491647f09dfe255
7 changes: 2 additions & 5 deletions crates/ruff_linter/src/rules/ruff/rules/sequence_sorting.rs
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ use ruff_python_ast as ast;
use ruff_python_codegen::Stylist;
use ruff_python_parser::{lexer, Mode, Tok, TokenKind};
use ruff_python_stdlib::str::is_cased_uppercase;
use ruff_python_trivia::{leading_indentation, SimpleTokenKind, SimpleTokenizer};
use ruff_python_trivia::{first_non_trivia_token, leading_indentation, SimpleTokenKind};
use ruff_source_file::Locator;
use ruff_text_size::{Ranged, TextRange, TextSize};

@@ -434,11 +434,8 @@ impl MultilineStringSequenceValue {
locator,
);

let mut postlude_tokens =
SimpleTokenizer::starts_at(TextSize::new(0), &postlude).skip_trivia();
let needs_trailing_comma = self.ends_with_trailing_comma
&& postlude_tokens
.next()
&& first_non_trivia_token(TextSize::new(0), &postlude)
.map_or(true, |tok| tok.kind() != SimpleTokenKind::Comma);
AlexWaygood marked this conversation as resolved.
Show resolved Hide resolved

self.items
Loading