Skip to content

Commit

Permalink
Use our own touch_import in fix_int_long_tuple, so absolute_imports i…
Browse files Browse the repository at this point in the history
…s added
  • Loading branch information
takluyver committed Sep 28, 2014
1 parent d175d40 commit 32baf14
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion libmodernize/fixes/fix_int_long_tuple.py
Expand Up @@ -2,6 +2,7 @@

from lib2to3 import fixer_base
from lib2to3 import fixer_util
from libmodernize import touch_import


class FixIntLongTuple(fixer_base.BaseFix):
Expand All @@ -20,6 +21,6 @@ def transform(self, node, results):
name = results['name']
name.replace(fixer_util.Name('int', prefix=name.prefix))
else:
fixer_util.touch_import(None, 'six', node)
touch_import(None, 'six', node)
pair = results['pair']
pair.replace(fixer_util.Name('six.integer_types', prefix=pair.prefix))
2 changes: 2 additions & 0 deletions tests/test_fix_int_long_tuple.py
Expand Up @@ -6,13 +6,15 @@
INT_LONG_ISINSTANCE = ("""\
isinstance(1, (int, long))
""", """\
from __future__ import absolute_import
import six
isinstance(1, six.integer_types)
""")

LONG_INT_ISINSTANCE = ("""\
isinstance(1, (long, int))
""", """\
from __future__ import absolute_import
import six
isinstance(1, six.integer_types)
""")
Expand Down

0 comments on commit 32baf14

Please sign in to comment.