From db8f2c2d9fec7cc6722fcfdd825189f14f839b68 Mon Sep 17 00:00:00 2001 From: Dhruv Manilawala Date: Wed, 12 Jun 2024 11:29:19 +0530 Subject: [PATCH] Use the existing `ruff_python_trivia::is_python_whitespace` function (#11844) ## Summary This PR re-uses the `ruff_python_trivia::is_python_whitespace` in the lexer instead of defining its own. This was mainly to avoid circular dependency which was resolved in #11261. --- crates/ruff_python_parser/src/lexer.rs | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/crates/ruff_python_parser/src/lexer.rs b/crates/ruff_python_parser/src/lexer.rs index 1dc686f5af..5e6b5b3160 100644 --- a/crates/ruff_python_parser/src/lexer.rs +++ b/crates/ruff_python_parser/src/lexer.rs @@ -18,6 +18,7 @@ use ruff_python_ast::str_prefix::{ AnyStringPrefix, ByteStringPrefix, FStringPrefix, StringLiteralPrefix, }; use ruff_python_ast::{AnyStringFlags, Int, IpyEscapeKind, StringFlags}; +use ruff_python_trivia::is_python_whitespace; use ruff_text_size::{Ranged, TextLen, TextRange, TextSize}; use crate::error::FStringErrorType; @@ -1807,20 +1808,6 @@ fn is_identifier_continuation(c: char, identifier_is_ascii_only: &mut bool) -> b } } -/// Returns `true` for [whitespace](https://docs.python.org/3/reference/lexical_analysis.html#whitespace-between-tokens) -/// characters. -/// -/// This is the same as `ruff_python_trivia::is_python_whitespace` and is copied -/// here to avoid a circular dependency as `ruff_python_trivia` has a dev-dependency -/// on `ruff_python_lexer`. -const fn is_python_whitespace(c: char) -> bool { - matches!( - c, - // Space, tab, or form-feed - ' ' | '\t' | '\x0C' - ) -} - enum LexedText<'a> { Source { source: &'a str, range: TextRange }, Owned(String),