File tree Expand file tree Collapse file tree 3 files changed +52
-0
lines changed Expand file tree Collapse file tree 3 files changed +52
-0
lines changed Original file line number Diff line number Diff line change 8
8
'lib2to3.fixes.fix_funcattrs' ,
9
9
'lib2to3.fixes.fix_has_key' ,
10
10
'lib2to3.fixes.fix_idioms' ,
11
+ 'lib2to3.fixes.fix_long' ,
11
12
'lib2to3.fixes.fix_methodattrs' ,
12
13
'lib2to3.fixes.fix_ne' ,
13
14
'lib2to3.fixes.fix_numliterals' ,
32
33
'libmodernize.fixes.fix_filter' ,
33
34
'libmodernize.fixes.fix_imports_six' ,
34
35
'libmodernize.fixes.fix_input_six' ,
36
+ 'libmodernize.fixes.fix_int_long_tuple' ,
35
37
'libmodernize.fixes.fix_map' ,
36
38
'libmodernize.fixes.fix_metaclass' ,
37
39
'libmodernize.fixes.fix_raise_six' ,
Original file line number Diff line number Diff line change
1
+ from __future__ import absolute_import
2
+
3
+ from lib2to3 import fixer_base
4
+ from lib2to3 import fixer_util
5
+
6
+
7
+ class FixIntLongTuple (fixer_base .BaseFix ):
8
+
9
+ run_order = 4 # Must run before fix_long.
10
+
11
+ PATTERN = """
12
+ pair=atom < '(' testlist_gexp < (
13
+ ('int' ',' 'long') |
14
+ ('long' ',' 'int')
15
+ ) > ')' >
16
+ """
17
+
18
+ def transform (self , node , results ):
19
+ if 'name' in results :
20
+ name = results ['name' ]
21
+ name .replace (fixer_util .Name ('int' , prefix = name .prefix ))
22
+ else :
23
+ fixer_util .touch_import (None , 'six' , node )
24
+ pair = results ['pair' ]
25
+ pair .replace (fixer_util .Name ('six.integer_types' , prefix = pair .prefix ))
Original file line number Diff line number Diff line change
1
+ from __future__ import absolute_import
2
+
3
+ from utils import check_on_input
4
+
5
+
6
+ INT_LONG_ISINSTANCE = ("""\
7
+ isinstance(1, (int, long))
8
+ """ , """\
9
+ import six
10
+ isinstance(1, six.integer_types)
11
+ """ )
12
+
13
+ LONG_INT_ISINSTANCE = ("""\
14
+ isinstance(1, (long, int))
15
+ """ , """\
16
+ import six
17
+ isinstance(1, six.integer_types)
18
+ """ )
19
+
20
+
21
+ def test_int_long_isinstance ():
22
+ check_on_input (* INT_LONG_ISINSTANCE )
23
+
24
+ def test_long_int_isinstance ():
25
+ check_on_input (* LONG_INT_ISINSTANCE )
You can’t perform that action at this time.
0 commit comments