Skip to content

Commit

Permalink
Fix COM812 false positive in string subscript
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanPlasse committed May 18, 2023
1 parent ddd541b commit d10ddab
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
8 changes: 8 additions & 0 deletions crates/ruff/resources/test/fixtures/flake8_commas/COM81.py
Original file line number Diff line number Diff line change
Expand Up @@ -631,3 +631,11 @@ def foo(
the_first_one = next(
(i for i in range(10) if i // 2 == 0) # COM812 fix should include the final bracket
)

foo = namedtuple(
name="foo",
status="bar",
message="sfdsdfsdgs fsdfsdf output!dsfdfsdjkg ghfskdjghkdssd sd fsdf s\n"[
:20
],
)
1 change: 1 addition & 0 deletions crates/ruff/src/rules/flake8_commas/rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ impl<'tok> Token<'tok> {
// Import treated like a function.
Tok::Import => TokenType::Named,
Tok::Name { .. } => TokenType::Named,
Tok::String { .. } => TokenType::Named,
Tok::Comma => TokenType::Comma,
Tok::Lpar => TokenType::OpeningBracket,
Tok::Lsqb => TokenType::OpeningSquareBracket,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -936,5 +936,7 @@ COM81.py:632:42: COM812 [*] Trailing comma missing
632 |- (i for i in range(10) if i // 2 == 0) # COM812 fix should include the final bracket
632 |+ (i for i in range(10) if i // 2 == 0), # COM812 fix should include the final bracket
633 633 | )
634 634 |
635 635 | foo = namedtuple(


0 comments on commit d10ddab

Please sign in to comment.