1 # Copyright 2006 Google, Inc. All Rights Reserved. 2 # Licensed to PSF under a Contributor Agreement. 3 4 """Fixer that transforms `xyzzy` into repr(xyzzy).""" 5 6 # Local imports 7 from .. import fixer_base 8 from ..fixer_util import Call, Name, parenthesize 9 10 11 class FixRepr(fixer_base.BaseFix): 12 13 BM_compatible = True 14 PATTERN = """ 15 atom < '`' expr=any '`' > 16 """ 17 18 def transform(self, node, results): 19 expr = results["expr"].clone() 20 21 if expr.type == self.syms.testlist1: 22 expr = parenthesize(expr) 23 return Call(Name(u"repr"), [expr], prefix=node.prefix) 24