Ignore trailing quotes for unclosed l-brace errors (#9388)
## Summary
Given:
```python
F"{"ڤ
```
We try to locate the "unclosed left brace" error by subtracting the
quote size from the lexer offset -- so we subtract 1 from the end of the
source, which puts us in the middle of a Unicode character. I don't
think we should try to adjust the offset in this way, since there can be
content _after_ the quote. For example, with the advent of PEP 701, this
string could reasonably be fixed as:
```python
F"{"ڤ"}"
````
Closes https://github.com/astral-sh/ruff/issues/9379.
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
use bitflags::bitflags;
|
||||
|
||||
use ruff_text_size::TextSize;
|
||||
|
||||
bitflags! {
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct FStringContextFlags: u8 {
|
||||
@@ -58,15 +56,6 @@ impl FStringContext {
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the number of quotes for the current f-string.
|
||||
pub(crate) const fn quote_size(&self) -> TextSize {
|
||||
if self.is_triple_quoted() {
|
||||
TextSize::new(3)
|
||||
} else {
|
||||
TextSize::new(1)
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the triple quotes for the current f-string if it is a triple-quoted
|
||||
/// f-string, `None` otherwise.
|
||||
pub(crate) const fn triple_quotes(&self) -> Option<&'static str> {
|
||||
|
||||
Reference in New Issue
Block a user