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
Trying to reformat list(i for i in range(10), ) fails with "Black produced code that is not equivalent to the source."
Passing a generator comprehension to a function as its sole argument with a trailing comma is valid in Python 2.7 but not in Python 3.7. (It is valid in Python 3.6 as well but typed_ast rejects it in 3.6 mode because it is based on the 3.7 parser... I expected the Python 3.8 parser rejects it as well.)
Black fails on this because the original code parses only in 2.7, so it gets a 2.7 AST. Once the trailing comma is removed, it parses in 3.7 as well, so gets a 3.7 AST, which will never match the 2.7 one.
I think the solution is probably to ensure that the same parser is used for before and after?
The text was updated successfully, but these errors were encountered:
This no longer crashes because we dropped support for 2.7.
Technically there's a bug here as this syntax works at runtime in 3.6 and Black rejects it even though we still support formatting Python 3.6, but I don't care.
Trying to reformat
list(i for i in range(10), )
fails with "Black produced code that is not equivalent to the source."Passing a generator comprehension to a function as its sole argument with a trailing comma is valid in Python 2.7 but not in Python 3.7. (It is valid in Python 3.6 as well but typed_ast rejects it in 3.6 mode because it is based on the 3.7 parser... I expected the Python 3.8 parser rejects it as well.)
Black fails on this because the original code parses only in 2.7, so it gets a 2.7 AST. Once the trailing comma is removed, it parses in 3.7 as well, so gets a 3.7 AST, which will never match the 2.7 one.
I think the solution is probably to ensure that the same parser is used for before and after?
The text was updated successfully, but these errors were encountered: