-
Notifications
You must be signed in to change notification settings - Fork 1.8k
[red-knot] No panic for illegal self-referential f-string annotations #14629
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,13 +27,17 @@ static EXPECTED_DIAGNOSTICS: &[&str] = &[ | |
| // We don't support `*` imports yet: | ||
| "error[unresolved-import] /src/tomllib/_parser.py:7:29 Module `collections.abc` has no member `Iterable`", | ||
| // We don't support terminal statements in control flow yet: | ||
| "error[annotation-with-invalid-expression] /src/tomllib/_parser.py:57:71 Invalid expression in type expression", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are several type annotations on this line, and it's hard to tell which annotation this is referring to without counting the columns. Could we improve the error message so it specifies which variable or annotation the diagnostic is complaining about?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Including arbitrary expressions is something that I'm always worried about because it can lead to very long messages, but including the name might be an option or David can come up with something that avoids this. What should help here is when we have rich diagnostics that also show a code frame
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When I wrote that error message, I was looking for something like a I'm happy to improve this error message though once we agree that this is even the right approach to begin with.
👍
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That should help for sure, but it's also useful to have important information in the summary line for when a user is using |
||
| "error[possibly-unresolved-reference] /src/tomllib/_parser.py:66:18 Name `s` used when possibly not defined", | ||
| "error[annotation-with-invalid-expression] /src/tomllib/_parser.py:69:66 Invalid expression in type expression", | ||
| "error[possibly-unresolved-reference] /src/tomllib/_parser.py:98:12 Name `char` used when possibly not defined", | ||
| "error[possibly-unresolved-reference] /src/tomllib/_parser.py:101:12 Name `char` used when possibly not defined", | ||
| "error[possibly-unresolved-reference] /src/tomllib/_parser.py:104:14 Name `char` used when possibly not defined", | ||
| "error[conflicting-declarations] /src/tomllib/_parser.py:108:17 Conflicting declared types for `second_char`: Unknown, str | None", | ||
| "error[possibly-unresolved-reference] /src/tomllib/_parser.py:115:14 Name `char` used when possibly not defined", | ||
| "error[possibly-unresolved-reference] /src/tomllib/_parser.py:126:12 Name `char` used when possibly not defined", | ||
| "error[annotation-with-invalid-expression] /src/tomllib/_parser.py:145:27 Invalid expression in type expression", | ||
| "error[annotation-with-invalid-expression] /src/tomllib/_parser.py:196:25 Invalid expression in type expression", | ||
| "error[conflicting-declarations] /src/tomllib/_parser.py:267:9 Conflicting declared types for `char`: Unknown, str | None", | ||
| "error[possibly-unresolved-reference] /src/tomllib/_parser.py:348:20 Name `nest` used when possibly not defined", | ||
| "error[possibly-unresolved-reference] /src/tomllib/_parser.py:353:5 Name `nest` used when possibly not defined", | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.