mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-24 05:26:23 +00:00
Add methods to iter over f-string elements (#10309)
## Summary This PR adds methods on `FString` to iterate over the two different kind of elements it can have - literals and expressions. This is similar to the methods we have on `ExprFString`. --------- Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
parent
93d582d734
commit
32d6f84e3d
4 changed files with 19 additions and 13 deletions
|
@ -138,9 +138,7 @@ impl FStringLayout {
|
|||
//
|
||||
// Reference: https://prettier.io/docs/en/next/rationale.html#template-literals
|
||||
if f_string
|
||||
.elements
|
||||
.iter()
|
||||
.filter_map(|element| element.as_expression())
|
||||
.expressions()
|
||||
.any(|expr| memchr::memchr2(b'\n', b'\r', locator.slice(expr).as_bytes()).is_some())
|
||||
{
|
||||
Self::Multiline
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue