Skip to content

sphinx.pycode.ast.unparse does not understand operator precedence #7498

@eric-wieser

Description

@eric-wieser

As an example:

>>> import sphinx.pycode.ast as ast
>>> ast.unparse(ast.parse("(1 + 2) * 3").body[0].value)
'1 + 2 * 3'
>>> ast.unparse(ast.parse("(1, 2) + (3, 4)").body[0].value)
'1, 2 + 3, 4'

Easiest way to fix this will be to copy some of the approach from the python 3.9 ast.unparse, which needs #7497 in order to keep track of the current precedence level.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions