mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-29 05:15:12 +00:00
[pyflakes
] Show syntax error message for F722
(#15523)
## Summary Ref: https://github.com/astral-sh/ruff/pull/15387#discussion_r1917796907 This PR updates `F722` to show syntax error message instead of the string content. I think it's more useful to show the syntax error message than the string content. In the future, when the diagnostics renderer is more capable, we could even highlight the exact location of the syntax error along with the annotation string. This is also in line with how we show the diagnostic in red knot. ## Test Plan Update existing test snapshots.
This commit is contained in:
parent
cf4ab7cba1
commit
79e52c7fdf
8 changed files with 80 additions and 88 deletions
|
@ -153,9 +153,7 @@ pub(crate) fn parse_string_annotation(
|
|||
} else if raw_contents(node_text)
|
||||
.is_some_and(|raw_contents| raw_contents == string_literal.as_str())
|
||||
{
|
||||
let parsed =
|
||||
ruff_python_parser::parse_string_annotation(source.as_str(), string_literal);
|
||||
match parsed {
|
||||
match ruff_python_parser::parse_string_annotation(source.as_str(), string_literal) {
|
||||
Ok(parsed) => return Some(parsed),
|
||||
Err(parse_error) => context.report_lint(
|
||||
&INVALID_SYNTAX_IN_FORWARD_ANNOTATION,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue