You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
misleading SyntaxError (f-string and type alias related) #109114
The wrong type alias does produce a syntax error when you put it by itself:
>>> type {}[name_4] = {}
File "<stdin>", line 1
type {}[name_4] = {}
^
SyntaxError: invalid syntax
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
Activity
AlexWaygood commentedon Sep 7, 2023
Cc. @pablogsal
Cc. @JelleZijlstra
JelleZijlstra commentedon Sep 7, 2023
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.
pablogsal commentedon Sep 8, 2023
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
pythongh-109114: Relax the check for invalid lambdas inside f-strings…
pythongh-109114: Relax the check for invalid lambdas inside f-strings…
pythongh-109114: Relax the check for invalid lambdas inside f-strings…
pythongh-109114: Relax the check for invalid lambdas inside f-strings…
gh-109114: Relax the check for invalid lambdas inside f-strings to av…
[3.12] pythongh-109114: Relax the check for invalid lambdas inside f-…
[3.12] pythongh-109114: Relax the check for invalid lambdas inside f-…
[3.12] gh-109114: Relax the check for invalid lambdas inside f-string…