[issue39760] ast.FormattedValue.format_spec unnecessarily wrapped in JoinedStr

2020-03-04 Thread Batuhan Taskaya
Change by Batuhan Taskaya : -- nosy: +BTaskaya versions: +Python 3.9 -Python 3.8 ___ Python tracker ___ ___ Python-bugs-list

[issue39760] ast.FormattedValue.format_spec unnecessarily wrapped in JoinedStr

2020-02-26 Thread Eric V. Smith
Eric V. Smith added the comment: > FYI you can use ast CLI: I did not know that. That's awesome, thanks for pointing it out. -- ___ Python tracker ___

[issue39760] ast.FormattedValue.format_spec unnecessarily wrapped in JoinedStr

2020-02-26 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: FYI you can use ast CLI: $ echo 'f"is {x:d}"' | ./python -m ast Module( body=[ Expr( value=JoinedStr( values=[ Constant(value='is ', kind=None), FormattedValue( value=Name(id='x',

[issue39760] ast.FormattedValue.format_spec unnecessarily wrapped in JoinedStr

2020-02-26 Thread Eric V. Smith
Eric V. Smith added the comment: I agree that could probably be simplified, if the format_spec is constant (which it need not be). >>> ast.dump(ast.parse('f"is {x:d}"')) "Module(body=[Expr(value=JoinedStr(values=[Str(s='is '), FormattedValue(value=Name(id='x', ctx=Load()), conversion=-1,

[issue39760] ast.FormattedValue.format_spec unnecessarily wrapped in JoinedStr

2020-02-26 Thread Ilya Kamenshchikov
New submission from Ilya Kamenshchikov : Most usual usecase for format_spec is to specify it as a constant, that would be logical to represent as ast.Constant. However, ast.parse wraps value of ast.FormattedValue.format_spec into a JoinedStr with a single constant value, as can be seen from