add fixer for reload() -> imp.reload() (closes #11797)\n\nPatch by Laurie Clark-Michalek and Berker Peksag

This commit is contained in:
Benjamin Peterson 2012-12-07 22:44:10 -05:00
parent e7f2186f99
commit 448e81b2da
7 changed files with 120 additions and 18 deletions

View file

@ -0,0 +1,28 @@
"""Fixer for reload().
reload(s) -> imp.reload(s)"""
# Local imports
from .. import fixer_base
from ..fixer_util import ImportAndCall, touch_import
class FixReload(fixer_base.BaseFix):
BM_compatible = True
order = "pre"
PATTERN = """
power< 'reload'
trailer< lpar='('
( not(arglist | argument<any '=' any>) obj=any
| obj=arglist<(not argument<any '=' any>) any ','> )
rpar=')' >
after=any*
>
"""
def transform(self, node, results):
names = ('imp', 'reload')
new = ImportAndCall(node, results, names)
touch_import(None, 'imp', node)
return new