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
|
/// The [`Locator`] for the current file, which enables extraction of source code from byte
|
||||||
/// offsets.
|
/// offsets.
|
||||||
pub(crate) const fn locator(&self) -> &'a Locator<'a> {
|
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 ("""...""")
|
// Check for parentheses outside the string ("""...""")
|
||||||
annotation_expr.into(),
|
annotation_expr.into(),
|
||||||
checker.semantic().current_statement().into(),
|
checker.semantic().current_statement().into(),
|
||||||
checker.tokens(),
|
checker.source_tokens(),
|
||||||
)
|
)
|
||||||
.is_none()
|
.is_none()
|
||||||
&& parenthesized_range(
|
&& parenthesized_range(
|
||||||
|
|
|
||||||
|
|
@ -470,8 +470,8 @@ help: Remove quotes
|
||||||
60 | # P, Q, and R should not have parenthesis added
|
60 | # P, Q, and R should not have parenthesis added
|
||||||
- p: TypeAlias = ("""int
|
- p: TypeAlias = ("""int
|
||||||
- | None""")
|
- | None""")
|
||||||
61 + p: TypeAlias = ((int
|
61 + p: TypeAlias = (int
|
||||||
62 + | None))
|
62 + | None)
|
||||||
63 | type P = ("""int
|
63 | type P = ("""int
|
||||||
64 | | None""")
|
64 | | None""")
|
||||||
65 |
|
65 |
|
||||||
|
|
@ -494,8 +494,8 @@ help: Remove quotes
|
||||||
62 | | None""")
|
62 | | None""")
|
||||||
- type P = ("""int
|
- type P = ("""int
|
||||||
- | None""")
|
- | None""")
|
||||||
63 + type P = ((int
|
63 + type P = (int
|
||||||
64 + | None))
|
64 + | None)
|
||||||
65 |
|
65 |
|
||||||
66 | q: TypeAlias = """(int
|
66 | q: TypeAlias = """(int
|
||||||
67 | | None)"""
|
67 | | None)"""
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue