Replies: 4 comments 16 replies
-
Yeah, what you outline is correct. Stringified annotations are a pain, and we don't have a good solution yet to support them well.
Whenever possible, I prefer to solve this in the parser using a new parser mode (so that we don't need to rewrite ruff). But it does require design on how to make this fit into the AST. I'm not sure if I remember it correctly but I believe @dhruvmanila wanted to look into this after this PTO but we can also support you designing and implementing this change if you're interested. CC: @carljm |
Beta Was this translation helpful? Give feedback.
-
On a slightly related note, is red knot going to resolve forward annotations the same way it does for "normal" annotations? Because of a backward compatibility behavior of |
Beta Was this translation helpful? Give feedback.
-
We do need to implement support for stringified annotations, which means we should have an open issue for it. So I am going to close this discussion for now and open an issue for implementing stringified annotations, with summaries of some of the things discussed here, and a reference back to this discussion. |
Beta Was this translation helpful? Give feedback.
-
Hi, I am opening a discussion as I am not sure this belongs in a github issue.
As I worked on future annotations in red-knot a short while ago, I noticed that there is no support for string annotations yet. I did locate a couple
// TODO
related to this.I might be interested in coding this feature at some point, however, I am not sure on how to proceed.
I know that given the string, I can use a the python parser to produce AST nodes and probably infer the type of a string annotation. However, this leads to problems in the current architecture as those AST nodes are not known for the SemanticIndex and symbols table.
Could we consider solving this by parsing StringAnnotations directly on the first run, making them into maybe a new variant? Or is there a way I don't see yet to achieve this by keeping those nodes as StringLiteral but parsing at inference time?
Beta Was this translation helpful? Give feedback.
All reactions