parens around consts when taking attr again

This commit is contained in:
rocky
2020-01-16 22:15:28 -05:00
parent 549c33113b
commit 6d368d2b30
6 changed files with 26 additions and 0 deletions

View File

@@ -1889,6 +1889,17 @@ class SourceWalker(GenericASTTraversal, object):
n_set = n_tuple = n_build_set = n_list
def n_store(self, node):
expr = node[0]
if expr == "expr" and expr[0] == "LOAD_CONST" and node[1] == "STORE_ATTR":
# FIXME: I didn't record which constants parenthesis is
# necessary. However, I suspect that we could further
# refine this by looking at operator precedence and
# eval'ing the constant value (pattr) and comparing with
# the type of the constant.
node.kind = "store_w_parens"
self.default(node)
def n_unpack(self, node):
if node[0].kind.startswith("UNPACK_EX"):
# Python 3+