Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions crates/ruff_python_ast/src/nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -773,10 +773,14 @@ pub trait StringFlags: Copy {
}

/// The total length of the string's closer.
/// This is always equal to `self.quote_len()`,
/// but is provided here for symmetry with the `opener_len()` method.
/// This is always equal to `self.quote_len()`, except when the string is unclosed,
/// in which case the length is zero.
fn closer_len(self) -> TextSize {
self.quote_len()
if self.is_unclosed() {
TextSize::default()
} else {
self.quote_len()
}
}

fn as_any_string_flags(self) -> AnyStringFlags {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -715,3 +715,17 @@ def _(a: int, b: str, c: int | str):
x9: int | str | None = f(lst(c))
reveal_type(x9) # revealed: int | str | None
```

## Forward annotation with unclosed string literal

Regression test for [#1611](https://github.com/astral-sh/ty/issues/1611).

<!-- blacken-docs:off -->

```py
# error: [invalid-syntax]
# error: [invalid-syntax-in-forward-annotation]
a:'
```

<!-- blacken-docs:on -->