mirror of
https://github.com/astral-sh/ruff
synced 2026-01-11 00:24:13 -05:00
Fix SimpleTokenizer's backward lexing of # (#5878)
This commit is contained in:
@@ -8,8 +8,7 @@ use ruff_python_ast::node::{AnyNodeRef, AstNode};
|
||||
use ruff_python_ast::source_code::Locator;
|
||||
use ruff_python_ast::whitespace;
|
||||
use ruff_python_trivia::{
|
||||
first_non_trivia_token_rev, PythonWhitespace, SimpleToken, SimpleTokenKind, SimpleTokenizer,
|
||||
UniversalNewlines,
|
||||
PythonWhitespace, SimpleToken, SimpleTokenKind, SimpleTokenizer, UniversalNewlines,
|
||||
};
|
||||
|
||||
use crate::comments::visitor::{CommentPlacement, DecoratedComment};
|
||||
@@ -1059,7 +1058,9 @@ fn handle_slice_comments<'a>(
|
||||
|
||||
// Check for `foo[ # comment`, but only if they are on the same line
|
||||
let after_lbracket = matches!(
|
||||
first_non_trivia_token_rev(comment.slice().start(), locator.contents()),
|
||||
SimpleTokenizer::up_to_without_back_comment(comment.slice().start(), locator.contents())
|
||||
.skip_trivia()
|
||||
.next_back(),
|
||||
Some(SimpleToken {
|
||||
kind: SimpleTokenKind::LBracket,
|
||||
..
|
||||
|
||||
Reference in New Issue
Block a user