feat: expose source_tokens() on Checker and fix regression for parenthesized_range()

This commit is contained in:
Denys Zhak 2025-12-10 19:34:35 +00:00
parent a8459522b7
commit ef3c373f85
3 changed files with 10 additions and 5 deletions

View File

@ -437,6 +437,11 @@ impl<'a> Checker<'a> {
}
}
/// Returns the [`Tokens`] for the parsed source file
pub(crate) fn source_tokens(&self) -> &'a Tokens {
self.parsed.tokens()
}
/// The [`Locator`] for the current file, which enables extraction of source code from byte
/// offsets.
pub(crate) const fn locator(&self) -> &'a Locator<'a> {

View File

@ -301,7 +301,7 @@ pub(crate) fn quoted_type_alias(
// Check for parentheses outside the string ("""...""")
annotation_expr.into(),
checker.semantic().current_statement().into(),
checker.tokens(),
checker.source_tokens(),
)
.is_none()
&& parenthesized_range(

View File

@ -470,8 +470,8 @@ help: Remove quotes
60 | # P, Q, and R should not have parenthesis added
- p: TypeAlias = ("""int
- | None""")
61 + p: TypeAlias = ((int
62 + | None))
61 + p: TypeAlias = (int
62 + | None)
63 | type P = ("""int
64 | | None""")
65 |
@ -494,8 +494,8 @@ help: Remove quotes
62 | | None""")
- type P = ("""int
- | None""")
63 + type P = ((int
64 + | None))
63 + type P = (int
64 + | None)
65 |
66 | q: TypeAlias = """(int
67 | | None)"""