mirror of https://github.com/astral-sh/ruff
feat: expose source_tokens() on Checker and fix regression for parenthesized_range()
This commit is contained in:
parent
a8459522b7
commit
ef3c373f85
|
|
@ -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> {
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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)"""
|
||||
|
|
|
|||
Loading…
Reference in New Issue