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
misleading SyntaxError (f-string and type alias related) #109114
Comments
Cc. @pablogsal
Cc. @JelleZijlstra |
The wrong type alias does produce a syntax error when you put it by itself:
I suspect there's some wrong heuristic in the parser where it simply shows the SyntaxError in the wrong place. That's outside my area of expertise though, so I'll leave this to Pablo. |
The problem is that the parser finds the issue in the error pass with the lambda first, even if is correct: that's why the type alias by itself raises. You can technically put whatever you want there that's invalid |
… to avoid false positives
… to avoid false positives Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
… to avoid false positives Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
… to avoid false positives Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
…strings to avoid false positives (pythonGH-109121). (cherry picked from commit 5bda2f6) Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
…strings to avoid false positives (pythonGH-109121). (cherry picked from commit 5bda2f6) Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com> Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
Bug report
Bug description:
The following code produces a misleading syntax error.
output (Python 3.12.0rc2+):
The first line should be valid python syntax and I would expect to get an syntax error for the wrong type alias name.
side note:
This is generated code. I found this issue during my work for the python 3.12 support for pysource-codegen.
CPython versions tested on:
3.12
Operating systems tested on:
Linux
Linked PRs
The text was updated successfully, but these errors were encountered: